Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dir.files(dirname, (filesError, files) => {
if (filesError) {
throwError(`while while getting input sources ${filesError}`);
}
// if no files in directory, then fire callback with empty sources
if (files.length === 0) {
callback(null, sources);
} else {
// read all files
dir.readFiles(dirname, (readFilesError, content, filename, next) => {
if (readFilesError) {
throwError(`while getting input sources ${readFilesError}`);
}
// parsed filename
const parsedDirName = dirname.replace('./', '');
const parsedFileName = filename.replace(parsedDirName, '').replace(/^\//, '');
const onlyFilename = filename.substr(filename.lastIndexOf('/') + 1);
// add input sources to output
if (filename.substr(filename.lastIndexOf('.') + 1) === 'sol'
&& filenameInclude(filename, exclude, include)
&& onlyFilename.charAt(0) !== '~'
&& onlyFilename.charAt(0) !== '#'
&& onlyFilename.charAt(0) !== '.') {
sources[parsedFileName] = content;
it("should load all schemas into an object", function(done) {
dir.readFiles(
baseDir, {
match: /.json$/
},
function(err, content, filename, next) {
if (err) throw err;
var name = path.relative(baseDir, filename);
loadedFiles[name] = content;
next();
},
function(err, files) {
if (err) {
console.log(err);
throw err;
}
var keys = Object.keys(loadedFiles);
it("should load all schemas into an object", function(done) {
dir.readFiles(
baseDir, {
match: /.json$/
},
function(err, content, filename, next) {
if (err) throw err;
var name = path.relative(baseDir, filename);
loadedFiles[name] = content;
next();
},
function(err, files) {
if (err) {
console.log(err);
throw err;
}
var keys = Object.keys(loadedFiles);
before(function(done) {
fixtures = {};
dir.readFiles(
path.join(path.dirname(module.filename), 'fixtures/schema/' + version),
function(err, content, filename, next) {
if (err) throw err;
fixtures[path.basename(filename, '.json')] = JSON.parse(content);
next();
},
function(err, files) {
if (err) throw err;
done();
}
);
});
return new Promise(function(resolve, reject) {
var mdFiles = {},
aliases = {},
dirOpts = { match: /.md/, exclude: /^_/ }
dir.readFiles(wikiPath, dirOpts, function (err, content, filename, next) {
if (!err) {
mdFiles[filename] = content
var base = path.basename(filename)
aliases[base.substr(0, base.length - 3)] = filename
}
next()
},
function (err, files) {
if (err) {
return reject(err)
}
logger.debug(
util.format(
'Found %d markdown files and %d links pointing to them in TOC',
Object.keys(mdFiles).length,
Object.keys(aliases).length
function getMdFiles(dirPath, match, callback) {
let data = [];
DIR.readFiles(dirPath, match || {match: /.md$/},
function (err, content, filename, next) {
if (err) throw err;
data.push(EXTEND(parseFileContent(filename, content), {page_url: filename.replace(/^.*source\//g, '')}));
next();
},
function (err, files) {
if (err) throw err;
callback(data.sort(sortListFromNewToOld));
});
}
const files = await new Promise((resolve, reject) => {
nodeDir.readFiles(process.cwd(), {
match: /\.codiusstate\.json$/, recursive: false
}, (err, content, next) => {
if (err) throw err
next()
}, (err, files) => {
if (err) reject(err)
resolve(files)
})
})
async.eachSeries(paths, function (p, icb) {
dir.readFiles(p, function (err, content, filePath, nextFile) {
if (content.charAt(0) === '\uFEFF')
content = content.substr(1);
var filename = path.basename(filePath, '.html');
if (options.studio !== "embed" || S(filename).startsWith("embed")) {
templates.push({
name: filename,
content: content
});
}
nextFile();
}, function () {
icb();
});
}, function () {
function traverseDir(path, result, done) {
dir.readFiles(
path,
{
match: extensions,
excludeDir: ignoreDir
},
function(error, content, filename, next) {
if (error) {
exitWithError(error);
}
try {
result[filename] = parser.parse(content);
} catch(error) {
writeError(error, path);
}
next();
},