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()
forceFileLoad(fileNameURL) { const fileName = fileURLToPath(fileNameURL); if (fileName.startsWith(this._embedderPath) && fs.existsSync(fileName)) this._client.filesChanged([{type: 'add', name: fileNameURL}]); }
// Resolve file paths in the same order as webpack const resolveModule = (resolveFn, filePath) => { const extension = moduleFileExtensions.find(extension => fs.existsSync(resolveFn(`${filePath}.${extension}`)) ); if (extension) { return resolveFn(`${filePath}.${extension}`); } return resolveFn(`${filePath}.js`); }
_(files) .flatMap(file => traverseUp(path.resolve(startFrom, file))) .sortBy().reverse() .filter(file => fs.existsSync(file) && path.isAbsolute(file)) .thru(files => _.isEmpty(files) ? [] : [_.first(files)]) .flatMap(dirFile => _.map(files, file => path.join(path.dirname(dirFile), file))) .filter(file => fs.existsSync(file)) .value()
// Helper for basic YAML const getYaml = (dest, options, lando) => { // Get existing lando if we have it const existingLando = (fs.existsSync(dest)) ? lando.yaml.load(dest) : {}; // Set the basics const landoConfig = {name: options.name, recipe: options.recipe}; // Set the webroot if we have one if (!_.isEmpty(options.webroot)) _.set(landoConfig, 'config.webroot', options.webroot); // Return merged YAML return _.merge(existingLando, landoConfig); }
// Let's also make a copy of caCert with the standarized .crt ending for better linux compat // See: https://github.com/lando/lando/issues/1550 lando.events.on('pre-engine-start', 3, data => { const caNormalizedCert = path.join(caDir, `${caDomain}.crt`); if (fs.existsSync(caCert) && !fs.existsSync(caNormalizedCert)) { // @NOTE: we need to use pre node 8.x-isms because pld roles with node 7.9 currently fs.writeFileSync(caNormalizedCert, fs.readFileSync(caCert)); } });
_(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()
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, }; }
function copyThemeDev() { if (!fs.existsSync('./build')) { log(buildNotFound); process.exit(1); } else { return src('./src/theme/**').pipe(dest('./build/wordpress/wp-content/themes/' + themeName)); } }
_(files) // Filter if file exists .filter(fs.existsSync) // Start collecting .reduce((a, file) => exports.merge(a, yaml.safeLoad(fs.readFileSync(file))), {})
// Helper to get init config const getInitConfig = dirs => _(dirs) .filter(dir => fs.existsSync(dir)) .flatMap(dir => glob.sync(path.join(dir, '*', 'init.js'))) .map(file => require(file)) .value()
/* * Toggle the secret toggle */ clearTaskCaches() { if (fs.existsSync(process.landoTaskCacheFile)) fs.unlinkSync(process.landoTaskCacheFile); if (fs.existsSync(process.landoAppTaskCacheFile)) fs.unlinkSync(process.landoAppTaskCacheFile); }
async function copyConfig() { if (await fs.existsSync('./wp-config.php')) { return src('./wp-config.php') .pipe(inject.after("define( 'DB_COLLATE', '' );", "\ndefine( 'DISABLE_WP_CRON', true );")) .pipe(dest('./build/wordpress')); } }
// Resolve file paths in the same order as webpack const resolveModule = (resolveFn, filePath) => { const extension = moduleFileExtensions.find(extension => fs.existsSync(resolveFn(`${filePath}.${extension}`)) ); if (extension) { return resolveFn(`${filePath}.${extension}`); } return resolveFn(`${filePath}.js`); }