Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var stat;
var pid = process.pid;
var mapFile = '/tmp/perf-' + pid + '.map';
t.ok(fs.existsSync(mapFile), 'map file exists')
stat = fs.statSync(mapFile);
var firstSize = stat.size;
// Linux flushes too aggressively
if (os.platform() === 'darwin')
t.equal(firstSize, 0, 'and on darwin its size is 0 since it has not been flushed yet')
flushAll();
stat = fs.statSync(mapFile);
// The below by itself is not really a proof since just calling 'flushAll' causes more JIT code to be generated which by
// itself would increase the map file size.
// However since Linux flushes more aggressively this is as good as we can do there.
// On darwin, we can show that before flushAll nothing got flushed and afterwards it did which is the
// actual proof that this works.
t.ok(stat.size > firstSize, 'after I flush all, the map file size is larger than before and non-zero since has been flushed')
console.log('size before flushAll()', firstSize);
console.log('size after flushAll()', stat.size);
t.end()
})
fs.readdirSync(path).forEach(function(first) { // database
var database = path + first;
assert.equal(fs.statSync(database).isDirectory(), true);
var metadata = '';
var collections = fs.readdirSync(database);
if (fs.existsSync(database + '/.metadata') === true) {
metadata = database + '/.metadata/';
delete collections[collections.indexOf('.metadata')]; // undefined is not a dir
}
collections.forEach(function(second) { // collection
var collection = database + '/' + second;
if (fs.statSync(collection).isDirectory() === false) {
return;
}
fs.readdirSync(collection).forEach(function(third) { // document
var document = collection + '/' + third;
if (next !== undefined) {
items.forEach((itemName: any) => {
let item = path.join(itemDir, itemName);
const stat = fs.statSync(item);
if (stat.isDirectory()) {
// /job/job1/job1.js
item = path.join(item, itemName + extension);
}
if (path.extname(item) === extension) {
if (fs.existsSync(item)) {
selectedItems.push(item);
}
}
});
function deleteObject(request, response) {
var filePath;
filePath = fileForUrl(request.url, false);
try {
fs.statSync(filePath);
} catch (e) {
debugDelete('file for url', request.url, 'does not exist');
respondWith(response, 403, JSON.stringify({error: 'Invalid request'}));
return;
}
respondWith(response, 204, '');
}
fs.readdirSync(resourcesDir).forEach(function (filename) {
var lcaseFilename = filename.toLowerCase(),
isDir = fs.statSync(path.join(resourcesDir, filename)).isDirectory();
if (this.blacklistDirectories.indexOf(lcaseFilename) !== -1) {
if (isDir) {
logger.error(__('Found blacklisted directory in the Resources directory') + '\n');
logger.error(__('The directory "%s" is a reserved word.', filename));
logger.error(__('You must rename this directory to something else.') + '\n');
} else {
logger.error(__('Found blacklisted file in the Resources directory') + '\n');
logger.error(__('The file "%s" is a reserved word.', filename));
logger.error(__('You must rename this file to something else.') + '\n');
}
process.exit(1);
} else if (this.graylistDirectories.indexOf(lcaseFilename) !== -1) {
if (isDir) {
logger.warn(__('Found graylisted directory in the Resources directory'));
logger.warn(__('The directory "%s" is potentially a reserved word.', filename));
function compile (path) {
if (!compiledTemplates[path]) {
compiledTemplates[path] = {
time: fs.statSync(path).mtime.getTime(),
template: handlebars.compile(fs.readFileSync(path, 'utf8'))
}
} else {
const newTime = fs.statSync(path).mtime.getTime()
if (compiledTemplates[path].time !== newTime) {
compiledTemplates[path] = {
time: newTime,
template: handlebars.compile(fs.readFileSync(path, 'utf8'))
}
}
}
return compiledTemplates[path].template
}
return fs.readdirSync(dir).filter((file) => {
return fs.statSync(path.join(dir, file)).isDirectory();
});
}
function readDir(dirPath: string, collectOrTranslate: boolean) {
let files = fs.readdirSync(dirPath);
for(let i = 0, len = files.length; i < len; i++) {
let filename = files[i];
let filePath = path.join(dirPath, filename);
let fileStat = fs.statSync(filePath);
if(fileStat.isFile()) {
let fileExt = path.extname(filename).toLowerCase();
if('.ts' == fileExt) {
if(collectOrTranslate) {
collectClass(filePath);
} else {
doTranslateFile(filePath);
}
}
} else {
readDir(filePath, collectOrTranslate);
}
}
}
function checkPath(path) {
return fs.existsSync(path) && !fs.statSync(path).isDirectory();
}
return fs.readdirSync(srcpath).filter(function(file) {
return fs.statSync(path.join(srcpath, file)).isFile() &&
file.indexOf('.js') > -1;
});
};