Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getTypoMapsPromise () {
return fsp
.readdir(typoMapsPath)
.then(fileNames => fileNames
.filter(name => /\.yaml$/.test(name))
.map(name => path.join(typoMapsPath, name))
)
.then(filePaths => Promise.all(
filePaths.map(filePath => fsp.readFile(filePath))
))
.then(fileContents => fileContents.map(yaml.safeLoad))
}
jsonfile.readFile(path.join(__dirname, 'schema.json')).then((schema) => {
fs.readdir(path.join(__dirname, 'banks')).then(files => lint(files, schema)).catch((err) => {
logError(err);
process.exit(1);
});
}).catch(logError);
const readFolder = () => {
if (!fs.statSync(SRC_DIR).isDirectory()) {
sourceFile = path.basename(SRC_DIR);
sourceDir = path.dirname(SRC_DIR);
return Promise.resolve([SRC_DIR])
}
return fs.readdir(SRC_DIR);
};
static getDirectories (dirPath) {
var dirs = [];
return FsPromise.readdir(dirPath).then(function(files) {
var promises = files.map(function (file) {
var fullPath = path.join(dirPath, file);
return FsPromise.stat(fullPath).then(function (stat) {
if (stat.isDirectory()) {
dirs.push(fullPath);
}
});
});
return Q.all(promises).thenResolve(dirs);
});
}
async function rmdirs(basePath: string) {
const stat = await fs.lstat(basePath);
if (stat.isDirectory()) {
const contents = await fs.readdir(basePath);
for (const file of contents) {
await rmdirs(path.resolve(basePath, file));
}
} else {
await fs.unlink(basePath);
}
}