本文整理汇总了TypeScript中shelljs.sed函数的典型用法代码示例。如果您正苦于以下问题:TypeScript sed函数的具体用法?TypeScript sed怎么用?TypeScript sed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sed函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: replaceVersionPlaceholders
function replaceVersionPlaceholders(filePath: string) {
if (stampData) {
const version = shx.grep('BUILD_SCM_VERSION', stampData).split(' ')[1].trim();
return shx.sed(/0.0.0-PLACEHOLDER/, version, filePath);
}
return shx.cat(filePath);
}
示例2: copyFile
function copyFile(file: string, baseDir: string, relative = '.') {
const dir = path.join(baseDir, relative);
shx.mkdir('-p', dir);
shx.cp(file, dir);
// Double-underscore is used to escape forward slash in FESM filenames.
// See ng_package.bzl:
// fesm_output_filename = entry_point.replace("/", "__")
// We need to unescape these.
if (file.indexOf('__') >= 0) {
const outputPath = path.join(dir, ...path.basename(file).split('__'));
shx.mkdir('-p', path.dirname(outputPath));
shx.mv(path.join(dir, path.basename(file)), outputPath);
// if we are renaming the .js file, we'll also need to update the sourceMappingURL in the file
if (file.endsWith('.js')) {
shx.chmod('+w', outputPath);
shx.sed('-i', `${path.basename(file)}.map`, `${path.basename(outputPath)}.map`, outputPath);
}
}
}
示例3: RegExp
tl.warning("No files found");
} else {
for (var i = 0; i < filesToReplace.length; i++) {
var file = filesToReplace[i];
console.info(`Changing version in ${file}`);
var contents = fs.readFileSync(file, 'utf8').toString();
var checkMatches = new RegExp(replaceRegex).exec(contents);
if (!checkMatches || checkMatches.length === 0) {
if (failIfNoMatchFound) {
tl.error(`No matches for regex [${replaceRegex}] found in file ${file}`);
process.exit(1);
} else {
tl.warning(`No matches for regex [${replaceRegex}] found in file ${file}`);
}
} else {
console.info(`${checkMatches.length} matches for regex [${replaceRegex}] found in file ${file}`);
// make the file writable
sh.chmod(666, file);
// replace all occurrences by adding g to the pattern
sh.sed("-i", new RegExp(replaceRegex, "g"), replacePrefix + versionNum, file);
}
}
console.info(`Processed ${filesToReplace.length} files`);
}
} else {
tl.warning(`Could not extract a version from [${buildNumber}] using pattern [${buildRegex}]`);
}
tl.debug("Leaving Version Assemblies step");