function initProjectFileOrDir(srcName, descName){ descName = descName || srcName; var srcFile = projectPath + '/' + srcName; var destFile = path.resolve(descName); if(fs.existsSync(destFile) === false){ fs.copySync(srcFile, destFile); console.log(descName.bold+' '+__(fs.statSync(srcFile).isDirectory()?'dir_created':'file_created').green); } }
function findPkgJson( target ) { let root = path.dirname( target ); while ( root !== '/' ) { const filepath = path.join( root, 'package.json' ); if ( fs.existsSync( filepath ) ) { return JSON.parse( fs.readFileSync( filepath, 'utf8' ) ); } root = path.join( root, '../' ); } throw new Error( 'could not find a pkg json' ); }
const mkdirsSync = function(dirname) { if (fs.existsSync(dirname)) { return true; } if (mkdirsSync(path.dirname(dirname))) { fs.mkdirSync(dirname); return true; } }
_(config.LANDO_METRICS_PLUGINS) .map(plugin => _.merge({}, plugin, {path: path.resolve(__dirname, 'plugins', `${plugin.name}.js`)})) .filter(plugin => fs.existsSync(plugin.path)) .map(plugin => _.merge({}, plugin, {Reporter: require(plugin.path)})) .value()
test('main', async t => { const cwd = tempy.directory(); try { await execa(path.join(__dirname, 'cli.js'), [path.join(__dirname, 'fixtures/Fixture.app')], {cwd}); } catch (error) { // Silence code signing failure if (!error.message.includes('Code signing failed')) { throw error; } } t.true(fs.existsSync(path.join(cwd, 'Fixture 0.0.1.dmg'))); });
_(fs.readdirSync(baseDir, {withFileTypes: true})) .filter(dirent => dirent.isDirectory()) .map(dirent => dirent.name) .concat('.') .map(directory => path.resolve(baseDir, directory, '.platform.app.yaml')) .filter(file => fs.existsSync(file)) .map(file => ({data: yamlPlatform.load(fs.readFileSync(file)), file})) .map(data => ({name: data.data.name, file: data.file, dir: path.dirname(data.file)})) .value()
getRecording(recording) { const recordingFilename = this.filenameFor(recording); if (fs.existsSync(recordingFilename)) { return this.respond(200, fs.readJsonSync(recordingFilename)); } return this.respond(204); }
constructor (api) { this.api = api this.pagesDir = api.config.pagesDir if (fs.existsSync(this.pagesDir)) { api.createManagedPages(args => this.createPages(args)) } }
/* * Toggle the secret toggle */ clearTaskCaches() { if (fs.existsSync(process.landoTaskCacheFile)) fs.unlinkSync(process.landoTaskCacheFile); if (fs.existsSync(process.landoAppTaskCacheFile)) fs.unlinkSync(process.landoAppTaskCacheFile); }
constructor(id, config = {}) { // Move our config into the userconfroot if we have some // NOTE: we need to do this because on macOS and Windows not all host files // are shared into the docker vm if (fs.existsSync(config.confSrc)) utils.moveConfig(config.confSrc, config.confDest); this.id = id; this.config = { proxy: config.proxy, services: config.services, tooling: config.tooling, }; }
export function ensureAppdataDirExists() { if (!fs.existsSync(appdataPath)) { fs.mkdirSync(appdataPath); } }
function getTemplateContent(isMobile) { var templateName = isMobile ? 'jwebdriver-mobile.js' : 'jwebdriver.js'; var tempalteFilePath = path.resolve(__dirname, '../template/' + templateName); var customTemplateFilePath = path.join(rootPath, './template/', templateName); if (fs.existsSync(customTemplateFilePath)) { tempalteFilePath = customTemplateFilePath; } return fs.readFileSync(tempalteFilePath).toString(); }
const copy = (source, dest) => { if (source && fs.existsSync(source) && fs.existsSync(dest)) { fs.unlinkSync(dest); fs.createReadStream(source).pipe(fs.createWriteStream(dest)); return; } throw new Error("not match"); }
function removeDir(installPath) { if (fs.existsSync(installPath)) { fse.removeSync(installPath); } }
constructor (api) { this.api = api this.pagesDir = api.config.pagesDir if (fs.existsSync(this.pagesDir)) { api.createManagedPages(args => this.createPages(args)) } }