_(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()
getCurrentVersion().then(({ latest }) => { packageJson.version = PRE_RELEASE_VERSION packageJson.kafkajs = { sha: commitSha, compare: `https://github.com/tulios/kafkajs/compare/v${latest}...${commitSha}`, } console.log(packageJson.kafkajs) const filePath = path.resolve(__dirname, '../../package.json') fs.writeFileSync(filePath, JSON.stringify(packageJson, null, 2)) console.log(`Package.json updated with pre-release version ${PRE_RELEASE_VERSION}`) })
/* * Create a data source */ create(source, data = {}, sort = []) { let database = this.read(source); database.push(_.merge({}, data, {id: hasher(data)})); // Sort if we have to if (!_.isEmpty(sort)) database = _.orderBy(database, ...sort); // Dump results this.yaml.dump(path.resolve(this.base, `${source}.yml`), _.uniqBy(database, 'id')); return this.read(source, {id: hasher(data)}); }
fs.readdirSync(inputFolder).forEach(function (dirContent) { dirContent = path.resolve(inputFolder, dirContent); if (getSubFolders && fs.statSync(dirContent).isDirectory()) { results = results.concat(helpers.findLUFiles(dirContent, getSubFolders, extType)); } if (fs.statSync(dirContent).isFile()) { if (dirContent.endsWith(extType)) { results.push(dirContent); } } });
_(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()
/* * Return a data source */ read(source, filters = {}) { const result = this.yaml.load(path.resolve(this.base, `${source}.yml`)) || []; if (!_.isEmpty(filters)) return _.filter(result, filters); return result; }
function setupNode() { const basePath = path.resolve(nodePath, isWin ? "" : "..") return trash(basePath) .then(() => fs.ensureLink(process.execPath, nodePath)) }
(process.env.NODE_PATH || '') .split(path.delimiter) .filter(folder => folder && !path.isAbsolute(folder)) .map(folder => path.resolve(appDirectory, folder)) .join(path.delimiter)
_(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()
// Protocol files are imported on demand depending on the APIs supported by Kafka, // but this behavior doesn't help Jest. Therefore, all files are eagerly imported // when running tests glob .sync('src/protocol/requests/**/v*/@(request|response).js') .map(file => path.resolve(file)) .map(require)
/* * Wipe the ENTIRE data source */ delete(source, id) { if (!id) throw Error('Specify a resource ID to remove!'); const database = _(this.read(source)).filter(item => item.id !== id).value(); this.yaml.dump(path.resolve(this.base, `${source}.yml`), database); return id; }
function setupRepo() { return Promise .all(trashPaths.map(trash)) .then(() => { if (! isWin) { const safeCharactersPath = path.resolve(fixturePath, "safe-characters[#%&;=].mjs") const unsafeCharactersPath = path.resolve(fixturePath, "unsafe-characters[\b\t\n\r:?].mjs") if (! fs.existsSync(unsafeCharactersPath)) { fs.copySync(safeCharactersPath, unsafeCharactersPath) } } }) }
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) } } }) }
(process.env.NODE_PATH || '') .split(path.delimiter) .filter(folder => folder && !path.isAbsolute(folder)) .map(folder => path.resolve(appDirectory, folder)) .join(path.delimiter)