本文整理汇总了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);
}
开发者ID:robwormald,项目名称:angular,代码行数:7,代码来源:packager.ts
示例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);
}
}
}
开发者ID:Cammisuli,项目名称:angular,代码行数:20,代码来源:packager.ts
示例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");
开发者ID:dixu99,项目名称:cols-agent-tasks,代码行数:31,代码来源:versionAssemblies.ts
注:本文中的shelljs.sed函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论