files.forEach((file) => { fs.readFile(file.file, 'utf8', (err, data) => { if (err) { throw err } const integrity = sriToolbox.generate({ algorithms: ['sha384'] }, data) console.log(`${file.configPropertyName}: ${integrity}`) sh.sed('-i', new RegExp(`(\\s${file.configPropertyName}:\\s+"|')(\\S+)("|')`), `$1${integrity}$3`, configFile) }) })
setUpStartPage () { logger.normal('cordova-paramedic: setting the app start page to the test page'); shell.sed('-i', 'src="index.html"', 'src="cdvtests/index.html"', 'config.xml'); }
function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) { original = new RegExp(regExpQuote(original), 'g') replacement = regExpQuoteReplacement(replacement) const updateFile = DRY_RUN ? (filepath) => { if (allowedExtensions.has(path.parse(filepath).ext)) { console.log(`FILE: ${filepath}`) } else { console.log(`EXCLUDED:${filepath}`) } } : (filepath) => { if (allowedExtensions.has(path.parse(filepath).ext)) { sh.sed('-i', original, replacement, filepath) } } walkAsync(directory, excludedDirectories, updateFile, (err) => { console.error('ERROR while traversing directory!:') console.error(err) process.exit(1) }) }
replacePackageVersion() { const sedResult = shell.sed( "-i", `(<PackageReference[ ]*Include[ ]*=[ ]*\"${this.packageName}\"[ ]*Version[ ]*=[ ]*\")([0-9]+.[0-9]+.[0-9]+)`, `$1${this.packageVersion}`, this.matchingProjects ); if (sedResult.code !== 0) { echo.error( `There was an error updating csproj files: ${sedResult}` ); shell.exit(sedResult.code); } echo.success( `Successfully updated '${this.packageName}' to version ${this.packageVersion}. Please check your git status before committing.` ); return 0; }
const exportServerConfig = (program, contracts) => { const tempFile = getTempFile(`server`) copyTemplate(`server`) shell.sed( `-i`, `CONTRACT_DECLARATIONS`, contractDeclarationString(contracts), tempFile ) shell.sed( `-i`, `CONTRACT_INSTANTIATION`, contractInstantiationString(program, contracts, `server`), tempFile ) return moveTemplateTo(tempFile, program.web3ServerPath) }
const exportClientConfig = (program, contracts) => { const tempFile = getTempFile(`client`) copyTemplate(`client`) shell.sed( `-i`, `PORTIS_DECLARATION`, `import { PortisProvider } from 'portis'`, tempFile ) shell.sed(`-i`, `PORTIS_PROVIDER`, portisConfigString(program), tempFile) shell.sed( `-i`, `CONTRACT_DECLARATIONS`, contractDeclarationString(contracts), tempFile ) shell.sed( `-i`, `CONTRACT_INSTANTIATION`, contractInstantiationString(program, contracts, `client`), tempFile ) return moveTemplateTo(tempFile, program.web3ClientPath) }
function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) { original = new RegExp(RegExp.quote(original), 'g'); replacement = RegExp.quoteReplacement(replacement); var updateFile = !DRY_RUN ? function (filepath) { if (allowedExtensions.has(path.parse(filepath).ext)) { sed('-i', original, replacement, filepath); } } : function (filepath) { if (allowedExtensions.has(path.parse(filepath).ext)) { console.log('FILE: ' + filepath); } else { console.log('EXCLUDED:' + filepath); } }; walkAsync(directory, excludedDirectories, updateFile, function (err) { console.error('ERROR while traversing directory!:'); console.error(err); process.exit(1); }); }
const updateMigration = (distPath, whichContract) => { const migrationFile = `${distPath}/migrations/2_deploy_contracts.js` let parameters switch (whichContract) { case `ERC721`: { parameters = `[\`Fun Token\`, \`FT\`]` break } case `RefundEscrow`: { parameters = `[contractOwner]` break } case `CappedCrowdsale`: { // TODO add support for multiple contract instantiations parameters = `[[1000],[10000, contractOwner, contract0]]` break } default: { parameters = `[\`Fun Token\`, \`FT\`, 18, 100000000]` } } const requireString = `artifacts.require(\`${whichContract}Adapter.sol\`)` console.log(` $ Updating Migration file:`, migrationFile) shell.sed(`-i`, `CONTRACT_PARAMS`, parameters, migrationFile) shell.sed(`-i`, `CONTRACT_REQUIRE`, requireString, migrationFile) }
shell.ls('package*.json').forEach(function (file) { shell.sed('-i', '@stencil/starter', projectName, file); });
shell.ls('package*.json').forEach(function (file) { shell.sed('-i', 'my-component', projectName, file); });
shell.ls('stencil.config.js').forEach(function (file) { shell.sed('-i', 'mycomponent', projectName, file); });
shell.ls('src/index.html').forEach(function (file) { shell.sed('-i', 'mycomponent', projectName, file); });
function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) { original = new RegExp(RegExp.quote(original), 'g'); replacement = RegExp.quoteReplacement(replacement); var updateFile = !DRY_RUN ? function (filepath) { if (allowedExtensions.has(path.parse(filepath).ext)) { sed('-i', original, replacement, filepath); } } : function (filepath) { if (allowedExtensions.has(path.parse(filepath).ext)) { console.log('FILE: ' + filepath); } else { console.log('EXCLUDED:' + filepath); } }; walkAsync(directory, excludedDirectories, updateFile, function (err) { console.error('ERROR while traversing directory!:'); console.error(err); process.exit(1); }); }
function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) { original = new RegExp(RegExp.quote(original), 'g'); replacement = RegExp.quoteReplacement(replacement); var updateFile = !DRY_RUN ? function (filepath) { if (allowedExtensions.has(path.parse(filepath).ext)) { sed('-i', original, replacement, filepath); } } : function (filepath) { if (allowedExtensions.has(path.parse(filepath).ext)) { console.log('FILE: ' + filepath); } else { console.log('EXCLUDED:' + filepath); } }; walkAsync(directory, excludedDirectories, updateFile, function (err) { console.error('ERROR while traversing directory!:'); console.error(err); process.exit(1); }); }