MCPcopy Create free account
hub / github.com/nodejs/node-addon-api / listOfTestModules

Function listOfTestModules

unit-test/listOfTestModules.js:39–64  ·  view source on GitHub ↗

* creates a configuration list for all available test modules * The configuration object contains the expected init function names and corresponding export property names

(currentDirectory = path.join(__dirname, '/../test'), pre = '')

Source from the content-addressed store, hash-verified

37 * The configuration object contains the expected init function names and corresponding export property names
38 */
39function listOfTestModules (currentDirectory = path.join(__dirname, '/../test'), pre = '') {
40 fs.readdirSync(currentDirectory).forEach((file) => {
41 if (file === 'binding.cc' ||
42 file === 'binding.gyp' ||
43 file === 'build' ||
44 file === 'common' ||
45 file === 'thunking_manual.cc' ||
46 file === 'addon_build' ||
47 file[0] === '.') {
48 return;
49 }
50 const absoluteFilepath = path.join(currentDirectory, file);
51 const fileName = file.toLowerCase().replace('.cc', '');
52 if (fs.statSync(absoluteFilepath).isDirectory()) {
53 buidDirs[fileName] = [];
54 listOfTestModules(absoluteFilepath, pre + file + '/');
55 } else {
56 if (!file.toLowerCase().endsWith('.cc')) return;
57 if (currentDirectory.trim().split('/test/').length > 1) {
58 buidDirs[currentDirectory.split('/test/')[1].toLowerCase()].push(fileName);
59 }
60 const relativePath = (currentDirectory.split(`${fileName}.cc`)[0]).split('/test/')[1] || '';
61 buildFiles[fileName] = { dir: relativePath, propertyName: getExportPropertyName(fileName), objectName: getExportObjectName(fileName) };
62 }
63 });
64}
65listOfTestModules();
66
67module.exports = {

Callers 1

Calls 2

getExportPropertyNameFunction · 0.85
getExportObjectNameFunction · 0.85

Tested by

no test coverage detected