Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function rmDir(pathname, next) {
fs.readdirSync(pathname).forEach(function(first) { // database
var database = pathname + first;
if (fs.statSync(database).isDirectory() === false) {
return;
}
var metadata = '';
var collections = fs.readdirSync(database);
var metadataPath = path.join(database, '.metadata');
if (fs.existsSync(metadataPath) === true) {
metadata = metadataPath + path.sep;
delete collections[collections.indexOf('.metadata')]; // undefined is not a dir
}
collections.forEach(function(second) { // collection
// Check return condition.
if (returnCallback && returnCallback(localPath, stats)) {
return results;
}
// Add current item.
results.push(localPath);
// No need for recursion if not a directory.
if (!stats.isDirectory()) {
return results;
}
// Iterate over list of children.
var list = fs.readdirSync(localPath);
list.forEach(function (file) {
file = localPath + "/" + file;
results = results.concat(walkSync(file, returnCallback));
});
return results;
}
.spread(function () {
var dirs = fs.readdirSync(sourceDir);
expect(arguments.length).to.equal(0);
expect(dirs).to.contain('0.0.1');
expect(dirs).to.contain('0.2.0');
next();
})
.done();
.then(function (dir) {
expect(dir).to.be.a('string');
var files = fs.readdirSync(dir);
expect(files).to.not.contain('foo');
expect(files).to.not.contain('bar');
expect(files).to.not.contain('baz');
next();
})
.done();
var destFolderExists = fs.existsSync(destFolder)
var performCopy = false
if (stats.isFile()) {
if (options.filter instanceof RegExp) {
console.warn('Warning: fs-extra: Passing a RegExp filter is deprecated, use a function')
performCopy = options.filter.test(src)
} else if (typeof options.filter === 'function') performCopy = options.filter(src)
if (performCopy) {
if (!destFolderExists) mkdir.mkdirsSync(destFolder)
copyFileSync(src, dest, {clobber: options.clobber, preserveTimestamps: options.preserveTimestamps})
}
} else if (stats.isDirectory()) {
if (!fs.existsSync(dest)) mkdir.mkdirsSync(dest)
var contents = fs.readdirSync(src)
contents.forEach(function (content) {
var opts = options
opts.recursive = true
copySync(path.join(src, content), path.join(dest, content), opts)
})
} else if (options.recursive && stats.isSymbolicLink()) {
var srcPath = fs.readlinkSync(src)
fs.symlinkSync(srcPath, dest)
}
}
this.loadConfig = function (reload) {
if (this._reloading) { return; }
this._reloading = true;
var localProjectsPath = common.paths.root('./projects');
var localProjects = [];
fs.readdirSync(localProjectsPath).map(function (filename) {
return common.paths.projects(filename);
}).forEach(function(item) {
if (path.basename(item).charAt(0) != '.') {
localProjects.push(item);
}
});
var configProjects = common.config.get('projects') || [];
this._projectDirs = configProjects.concat(localProjects);
var projects = {};
var added = [];
var removed = merge({}, this._projects);
var f = ff(this, function() {
this._projectDirs.forEach(function (dir) {
var next = f.wait();
function copyDir (src, dest, opts) {
fs.readdirSync(src).forEach(item => {
startCopy(path.join(src, item), path.join(dest, item), opts)
})
}
entry: {
main: [
'./src/server'
]
},
target: 'node',
output: {
library: true,
libraryTarget: 'commonjs2',
pathinfo: true,
path: path.join(__dirname, '../server/build'),
filename: '[name].js',
chunkFilename: '[name].js',
publicPath: '/build/'
},
externals: fs.readdirSync(path.join(__dirname, '../node_modules'))
.map(key => new RegExp(`^${key}`))
});
getFiles: function (srcpath) {
return fs.readdirSync(srcpath).filter(function (file) {
return fs.statSync(path.join(srcpath, file)).isFile();
});
},
rm: function (filename) {
readdirSync(p) {
try {
return fs.readdirSync(p).map(f => {
return normalizePath(path.join(p, f));
});
} catch (e) {}
return [];
},
readFile(p) {