// Get all mocha test files DirectoryAll.forEach(function(element) { FS.readdirSync(element) .filter(function(file) { return file.substr(-3) === '.js'; }) .forEach(function(file) { MochaInstanceAll.addFile(PT.join(element, file)); }); });
test('\'npm install-test\' should not generate package-lock.json.*', function (t) { common.npm(['install-test'], EXEC_OPTS, function (err, code, stderr, stdout) { if (err) throw err t.comment(stdout.trim()) t.comment(stderr.trim()) t.is(code, 0, 'npm install did not raise error code') var files = fs.readdirSync(pkg).filter(function (f) { return f.indexOf('package-lock.json.') === 0 }) t.notOk( files.length > 0, 'package-lock.json.* should not be generated: ' + files ) t.end() }) })
// Take a path and return an array that will contain the entire file list located at that path (sub directories and // everything). For a file the matching array element will be a String containing it's name (no path). For a directory // the matching element is going to be an Object that has a `name` key that holds the directory name (String) and a // `tree` key that holds an Array returned from readDirTree function readDirTree(path) { var dirTree = fs.readdirSync(path); var n = dirTree.length; var name; var innerPath; var stats; var dir; while (n--) { name = dirTree[n]; innerPath = resolvePath(path, name); stats = fs.lstatSync(innerPath); if (stats.isDirectory()) { // Create dir object dir = new Dir(name, readDirTree(innerPath)); // Replace dir name with dir tree dirTree[n] = dir; } } return dirTree; }