async readModules() { const packageJson = JSON.parse(await fs.readFile("package.json", "utf-8")); const files = await Promise.all( Object.keys(packageJson.dependencies).map(async module => { if (R.endsWith("-schema", module)) { return this.readModuleFiles(path.join("node_modules", module)); } return []; }) ); return files.reduce((a, b) => a.concat(b)); }
async function updateManifestVersionNumber(manifestPath) { const manifestText = await fs.readFile(manifestPath, 'utf-8'); const manifest = JSON.parse(manifestText); const v = manifest.version.split('.'); const buildNumber = Number(v.pop()) + 1; v.push(buildNumber); manifest.version = v.join('.'); console.info(`New version: ${manifest.version}`); await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 4)); return manifest.version; }
async function loadGitHubUsernameCache() { const path = `${__dirname}/github_username_cache.json`; if (await fs.exists(path)) { const jsonString = await fs.readFile(path); return JSON.parse(jsonString); } return {}; }
describe('LU instance', function() { const response = require('./../../fixtures/translation/serviceresponses/intentsAndutterances.json') before(function(){ nock('https://api.cognitive.microsofttranslator.com') .post(/.*/) .reply(200, response) }) it('Transalte LU instance content', async () => { let luContent = await fs.readFile(path.join(__dirname, './../../fixtures/translation/files/intentsAndUtterances.lu')) let result = await fs.readFile(path.join(__dirname, './../../fixtures/translation/translatedfiles/intentsAndUtterances.lu')) const luInstance = new LU(luContent.toString()) await luInstance.translate('xxxxxxx', 'fr', true, false) compareLuFiles(luInstance.content, result) }); });
const loadLuFile = async function(filePath) { let fileContent = await fs.readFile(path.join(__dirname, filePath)) return sanitize(fileContent) }
async dataSchemaFiles(includeDependencies) { const self = this; const files = await self.getFiles(""); let result = await Promise.all( files .filter(file => R.endsWith(".js", file)) .map(async file => { const content = await fs.readFile(path.join(self.localPath(), file), "utf-8"); return { fileName: file, content }; }) ); if (includeDependencies) { result = result.concat(await this.readModules()); } return result; }
const content = (yield fs.readFile(absTo)).toString(); const injectResult = injector(action, content);
const content = await fs.readFile(poFile, 'utf-8');
/*#__PURE__*/ function () { var _ref = _asyncToGenerator(function* (args, config) { return yield getFiles(args.actionfolder).then(things => things.sort((a, b) => a.localeCompare(b))) // TODO: add a test to verify this sort .then(filter(f => !ignores.find(ig => f.endsWith(ig)))) // TODO: add a // test for ignoring prompt.js and index.js .then(filter(file => args.subaction ? file.match(args.subaction) : true)).then(map(file => fs.readFile(file).then(text => ({ file, text: text.toString() })))).then(_ => Promise.all(_)).then(map(({ file, text }) => Object.assign({ file }, fm(text)))).then(map(({ file, attributes, body }) => ({ file, attributes: Object.entries(attributes).reduce((obj, [key, value]) => (obj[key] = renderTemplate(value, args, config)) && obj, {}), body: renderTemplate(body, args, config) }))); }); return function render(_x2, _x3) { return _ref.apply(this, arguments); }; }()
/** * @description Init the system, connect to docker if in docker * @example * init(); */ async function init() { // Clean temp folder await fse.emptyDir(this.config.tempFolder); // Ensure temp directory exists await fse.ensureDir(this.config.tempFolder); // we get Gladys version from package.json const packageJsonString = await fse.readFile(path.join(__dirname, '../../../package.json'), 'utf8'); const packageJson = JSON.parse(packageJsonString); // and save it in the object this.gladysVersion = `v${packageJson.version}`; try { // we create a new dockerode instance const dockerode = new this.Docker(); // if we can contact a docker daemon, this should not fail await dockerode.listContainers(); // and we should go there. // If it fails, it will go to catch and it means // docker dameon is not available on this machine. this.dockerode = dockerode; } catch (e) { if (e && e.errno === 'ENOENT') { logger.info(`System.init: This system doesn't have a docker dameon available.`); } } }
const stats = await fs.lstat(fileName); if (!stats.isDirectory()) { const content = await fs.readFile(fileName, 'utf-8'); return [
async function insertChangelog(tag, changelog) { const currentText = await fs.readFile(changelogPath, 'UTF-8'); const lines = currentText.split('\n');
.output(writeStream) .on('end', async () => { const image = await fse.readFile(filePath);
async readModuleFiles(modulePath) { const files = await fs.readdir(modulePath); return (await Promise.all( files.map(async file => { const fileName = path.join(modulePath, file); const stats = await fs.lstat(fileName); if (stats.isDirectory()) { return this.readModuleFiles(fileName); } else if (R.endsWith(".js", file)) { const content = await fs.readFile(fileName, "utf-8"); return [ { fileName, content, readOnly: true } ]; } else { return []; } }) )).reduce((a, b) => a.concat(b), []); }
console.info('Updating Readme URL...'); let readmeContent = await fs.readFile('README.md', 'utf8'); readmeContent = readmeContent.replace(/(https:\/\/github.com\/laurent22\/joplin-android\/releases\/download\/android-v\d+\.\d+\.\d+\/joplin-v\d+\.\d+\.\d+\.apk)/, releaseFiles['main'].downloadUrl); readmeContent = readmeContent.replace(/(https:\/\/github.com\/laurent22\/joplin-android\/releases\/download\/android-v\d+\.\d+\.\d+\/joplin-v\d+\.\d+\.\d+-32bit\.apk)/, releaseFiles['32bit'].downloadUrl); const uploadUrl = uploadUrlTemplate.expand({ name: releaseFile.apkFilename }); const binaryBody = await fs.readFile(releaseFile.apkFilePath);