const getDialogFiles = async function (inputFolder, results) { fs.readdirSync(inputFolder).forEach(async dirContent => { dirContent = path.resolve(inputFolder, dirContent) if (fs.statSync(dirContent).isDirectory()) { await getDialogFiles(dirContent, results) } if (fs.statSync(dirContent).isFile()) { if (dirContent.endsWith(dialogExt)) { results.push(dirContent) } } }) }
text = text.replace(this.includePattern, (match: string, includesPath: string) => { includesPath = path.join(this.includes!, includesPath.trim()); if (fs.existsSync(includesPath) && fs.statSync(includesPath).isFile()) { const contents = fs.readFileSync(includesPath, 'utf-8'); if (includesPath.substr(-4).toLocaleLowerCase() === '.hbs') {
const stat = fs.statSync(f); return !stat.isDirectory(); };
/** * Wrapper for `fs.statSync`. * @returns {object} Instance of `fs.Stats` for the node. */ statSync() { return this.fs.statSync(this.pathName, ...arguments); }
static getLogDirectory() { if (Command.APP_NAME === null) { throw Error('No app name set'); } try { fs.statSync(paths.log); } catch (e) { fs.mkdirsSync(paths.log); } return paths.log; }
//https://gist.github.com/kethinov/6658166#gistcomment-2109513 edited a bit. //returns a list of all the files in a folder and its subfolders, relative to the folder, flattened function walkSyncFlat(d) { return fs.statSync(d).isDirectory() ? Array.prototype.concat(...fs.readdirSync(d).map(f => walkSyncFlat(path.join(d,f)))) : d; }
describe('TokenMiddleware (prepare check)', () => { it('# LoadFakeParseCliArguments#selfTest', () => { fakeParseCliArguments.selfTest() }); it('# token file directory is existed', () => { Assert(fs.statSync(tokenFileDir).isDirectory()).isTrue(); }); });
const getTokenFilePath = (fileName, checked = true) => { const p = path.join(tokenFileDir, fileName); if (checked) Assert(fs.statSync(p).isFile()).isTrue(); return p; }
function walk(currentPath, level) { // give the current item a name & level const item = { name: path.basename(currentPath), level }; // get its stats const stats = fs.statSync(currentPath); // look at the item's contents if it has any if (stats.isDirectory()) { item.children = fs.readdirSync(currentPath).map(child => walk(path.join(currentPath, child), level + 1)); } return item; }
function exists (path) { try { fs.statSync(path) return true } catch (error) { if (error.code === 'ENOENT') return false throw error } }
static getCacheDirectory() { if (Command.APP_NAME === null) { throw Error('No app name set'); } try { fs.statSync(paths.cache); } catch (e) { fs.mkdirsSync(paths.cache); } return paths.cache; }
static getConfigDirectory() { if (Command.APP_NAME === null) { throw Error('No app name set'); } try { fs.statSync(paths.config); } catch (e) { fs.mkdirsSync(paths.config); } return paths.config; }
function fileExistsSync(path) { let exists = false; try { exists = fs.statSync(path); } catch (err) { exists = false; } return !!exists; }
/** * Checks if a file exists * @private * @param {string} path The filename to check. * @return {boolean} fileExists */function checkOutfile(path){var fileExists=null;try{fs.statSync(path);fileExists=true;}catch(e){if(e.code==='ENOENT')fileExists=false;}return fileExists;}
//https://gist.github.com/kethinov/6658166#gistcomment-2109513 edited a bit. //returns a list of all the files in a folder and its subfolders, relative to the folder, flattened function walkSyncFlat(d) { return fs.statSync(d).isDirectory() ? Array.prototype.concat(...fs.readdirSync(d).map(f => walkSyncFlat(path.join(d,f)))) : d; }