async downloadPackages() { await this.downloadRepo(); await decompress(this.repoArchivePath, this.tmpFolderPath, { plugins: [decompressTargz()], }); const dir = fs.readdirSync(this.tmpFolderPath).find((name) => !name.endsWith('tar.gz')); await executeCommand('npm', ['install'], { cwd: path.resolve(this.tmpFolderPath, dir) }); return { packagesPath: path.join(this.tmpFolderPath, dir, 'packages'), }; }
function availableLocales(defaultLocale) { const output = [defaultLocale]; fs.readdirSync(cliLocalesDir).forEach((path) => { if (fileExtension(path) !== 'po') return; const locale = filename(path); if (locale === defaultLocale) return; output.push(locale); }); return output; }
async function main() { const files = fs.readdirSync(cliLocalesDir); let hasErrors = false; for (const file of files) { if (!file.endsWith('.po')) continue; const fullPath = `${cliLocalesDir}/${file}`; try { await execCommand(`msgfmt -v "${fullPath}"`); } catch (error) { hasErrors = true; console.error(error); } } if (hasErrors) throw new Error('Some .po files could not be validated'); }
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) } } }) }
function isEmpty(dirPath) { return ! fs.readdirSync(dirPath).length }
projects.forEach(({ name, docsPath, outputDir }) => { const tmpDir = path.join(outputDir, 'tmp'); const project = app.convert(app.expandInputFiles([docsPath])); if (project) { app.generateDocs(project, tmpDir); if (fs.existsSync(tmpDir)) { const [tmpFileName] = fs.readdirSync(tmpDir); const pathArr = tmpDir.split('/'); pathArr.splice(-1, 1); const out = path.join(...pathArr); const currentPath = path.join(out, `${name}.md`); fs.copyFileSync(path.join(tmpDir, tmpFileName), currentPath); fs.removeSync(tmpDir); } } else { console.error(`Error while generating '${name}' docs`); } });
const files = fs.readdirSync(dir);
async function main() { const notes = []; const tagIdsToTag = {}; const filenames = fs.readdirSync(welcomeDir);
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; }
checkProjectType(){ if(this.wordupProject.wPkg('type') === 'installation'){ let srcFiles = [] try{ srcFiles = fs.readdirSync(this.wordupProject.getProjectPath(this.wordupProject.wPkg('srcFolder', 'src'))) }catch(e){} if(srcFiles.length > 0){ this.error('Your source folder is not empty. Projects with type "installation" need an empty source folder in order to be installed correctly.',{exit:1}) } } }
listPlatforms(projectDir) { const platforms = require('../platform/platforms') const platformsDir = path.join(projectDir, 'platforms') if (!fse.existsSync(platformsDir)) { return [] } const subdirs = fse.readdirSync(platformsDir) return subdirs.filter(function(p) { return Object.keys(platforms).indexOf(p) > -1 }) }
//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; }
// Read the directory and find the commands fs.readdirSync(commandsDir).filter( // Don't treat non-js files as commands, but also make sure any commands that are folders // with index.js files in them are loaded command => path.extname(command) === '.js' || fs.existsSync(path.join(commandsDir, command, 'index.js')) ).forEach((command) => { const basename = path.basename(command, '.js'); const commandName = commands[basename] ? `${extensionName}:${basename}` : basename; commands[commandName] = path.resolve(commandsDir, basename); });
function readAllFiles(dir) { var files = fs.readdirSync(dir); var certs = []; files.forEach((file_name) => { let file_path = path.join(dir,file_name); let data = fs.readFileSync(file_path); certs.push(data); }); return certs; }
folders.reduce((files, folder) => { return files.concat( fs .readdirSync(path.join(ownPath, folder)) // set full path .map(file => path.join(ownPath, folder, file)) // omit dirs from file list .filter(file => fs.lstatSync(file).isFile()) ); }, [])