tape("styleFiles", (test) => { test.plan(4); fs.readdir("./style", function readdir(err, files) { test.ifError(err); files.forEach(function forFile(file) { test.ok(require(path.join("../style", file)), "Unable to load/parse."); }); test.end(); }); });
function clearBabelCache(cachePath) { const babelCachePath = resolve(cachePath, "../@babel/register") const cacheNames = readdir(babelCachePath) for (const cacheName of cacheNames) { if (isExtJSON(cacheName)) { removeFile(babelCachePath + sep + cacheName) } } }
fs.readdir("./icons", function (err, files) { extract(files); if (!fs.existsSync("./dist")) { fs.mkdirSync("./dist"); } fs.writeFile('./dist/icons.json', JSON.stringify(svgObject), (err) => { if (err) throw err; console.log(chalk.whiteBright.bgBlack.bold("Created [JSON] for SVG Icons !! ")); }); });
test(`coverage is ignored if it's ${JSON.stringify(arg)}`, function (t) { t.plan(2) const cwd = tempy.directory() const nyc = path.join(cwd, '.nyc_output') cc.write(cwd, arg, function (err) { t.ifError(err) fs.readdir(nyc, function (err) { t.is(err.code, 'ENOENT') }) }) })
/** * Deletes an API backup folder * @param {string} uid content type uid */ async function deleteBackup(uid) { const { apiName } = strapi.contentTypes[uid]; const backupFolder = path.join(strapi.dir, 'api', '.backup'); const apiBackupFolder = path.join(strapi.dir, 'api', '.backup', apiName); await fse.remove(apiBackupFolder); const list = await fse.readdir(backupFolder); if (list.length === 0) { await fse.remove(backupFolder); } }
this._asyncFSwrapper.readdir(tcwd).catch(err => { console.warn(err); if (this._noTracking === true && this.dirpath) { // #262 this.setFailedState(); setTimeout(() => { this.readFS(this.dirpath); }, 1000); } else { this.setFailedState(); } })
function clean (dir, cb) { fs.readdir(dir, function (err, entries) { if (err) return cb(err) const pathsToRemove = entries .filter(entry => /^(\.clinic|\d+\.clinic-\w+(\.html)?|node_trace\.\d+\.log)$/.test(entry)) .map(entry => path.join(dir, entry)) async.eachSeries( pathsToRemove, (entry, next) => rimraf(entry, { disableGlob: true }, next), cb ) }) }
const loadLocalPluginsHooks = async (appPath, hooks) => { const pluginsDir = path.resolve(appPath, 'plugins'); if (!fs.existsSync(pluginsDir)) return; const pluginsNames = await fs.readdir(pluginsDir); for (let pluginName of pluginsNames) { // ignore files const stat = await fs.stat(path.resolve(pluginsDir, pluginName)); if (!stat.isDirectory()) continue; const dir = path.resolve(pluginsDir, pluginName, 'hooks'); await loadHooksInDir(dir, hooks); } }
async getFiles(dir, fileList = []) { const files = await fs.readdir(path.join(this.localPath(), dir)); // eslint-disable-next-line no-restricted-syntax for (const file of files) { const stat = await fs.stat(path.join(this.localPath(), dir, file)); if (stat.isDirectory()) { fileList = await this.getFiles(path.join(dir, file), fileList); } else fileList.push(path.join(dir, file)); } return fileList; }
test.before(async () => { const files = await pify(fs.readdir)('rules'); ruleFiles = files.filter(file => path.extname(file) === '.js'); });
const afterAll = () => { return new Promise(resolve => { fs.readdir(directory, (err, files) => { if (err) throw err; for (const file of files) { fs.unlink(path.join(directory, file), err => { if (err) { throw err; } else { resolve(); } }); } }); }); }
this._asyncFSwrapper.readdir(tcwd).catch(err => { console.warn(err); if (this._noTracking === true && this.dirpath) { // #262 this.setFailedState(); setTimeout(() => { this.readFS(this.dirpath); }, 1000); } else { this.setFailedState(); } })
const loadLocalPluginsHooks = async (appPath, hooks) => { const pluginsDir = path.resolve(appPath, 'plugins'); if (!fs.existsSync(pluginsDir)) return; const pluginsNames = await fs.readdir(pluginsDir); for (let pluginName of pluginsNames) { // ignore files const stat = await fs.stat(path.resolve(pluginsDir, pluginName)); if (!stat.isDirectory()) continue; const dir = path.resolve(pluginsDir, pluginName, 'hooks'); await loadHooksInDir(dir, hooks); } }
/** * Deletes an API backup folder * @param {string} uid content type uid */ async function deleteBackup(uid) { const { apiName } = strapi.contentTypes[uid]; const backupFolder = path.join(strapi.dir, 'api', '.backup'); const apiBackupFolder = path.join(strapi.dir, 'api', '.backup', apiName); await fse.remove(apiBackupFolder); const list = await fse.readdir(backupFolder); if (list.length === 0) { await fse.remove(backupFolder); } }
const afterAll = () => { return new Promise(resolve => { fs.readdir(directory, (err, files) => { if (err) throw err; for (const file of files) { fs.unlink(path.join(directory, file), err => { if (err) { throw err; } else { resolve(); } }); } }); }); }