當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript shelljs.sed函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。