Skip to content

Commit

Permalink
fixup!
Browse files Browse the repository at this point in the history
  • Loading branch information
RaisinTen committed Jan 8, 2021
1 parent 972c3c3 commit eb14116
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,40 @@ process.config.target_defaults.default_configuration =

let testModules = [];

fs.readdirSync(__dirname).forEach((file) => {
if (file !== 'binding.cc' &&
file !== 'binding.gyp' &&
file !== 'build' &&
file !== 'common' &&
file !== 'napi_child.js' &&
file !== 'testUtil.js' &&
file !== 'thunking_manual.cc' &&
file !== 'thunking_manual.js' &&
file !== 'index.js' &&
file[0] !== '.') {
const absoluteFilepath = path.join(__dirname, file);
// TODO(RaisinTen): Update this when the test filenames
// are changed into test_*.js.
function loadTestModules(currentDirectory = __dirname, pre = '') {
fs.readdirSync(currentDirectory).forEach((file) => {
if (currentDirectory === __dirname && (
file === 'binding.cc' ||
file === 'binding.gyp' ||
file === 'build' ||
file === 'common' ||
file === 'napi_child.js' ||
file === 'testUtil.js' ||
file === 'thunking_manual.cc' ||
file === 'thunking_manual.js' ||
file === 'index.js' ||
file[0] === '.')) {
return;
}
const absoluteFilepath = path.join(currentDirectory, file);
if (fs.statSync(absoluteFilepath).isDirectory()) {
if(fs.existsSync(absoluteFilepath + '/index.js')) {
testModules.push(file);
if (fs.existsSync(absoluteFilepath + '/index.js')) {
testModules.push(pre + file);
} else {
fs.readdirSync(absoluteFilepath).forEach((internalFile) => {
const internalFilepath = file + '/' + internalFile;
testModules.
push(internalFilepath.substr(0, internalFilepath.indexOf('.')));
});
loadTestModules(absoluteFilepath, pre + file + '/');
}
} else {
testModules.push(file.substr(0, file.indexOf('.')));
const parsedFilepath = path.parse(file);
if (parsedFilepath.ext === '.js') {
testModules.push(pre + parsedFilepath.name);
}
}
}
});
});
}

testModules = [...new Set(testModules)];
loadTestModules();

let napiVersion = Number(process.versions.napi)
if (process.env.NAPI_VERSION) {
Expand Down

0 comments on commit eb14116

Please sign in to comment.