本文整理汇总了TypeScript中vso-task-lib.glob函数的典型用法代码示例。如果您正苦于以下问题:TypeScript glob函数的具体用法?TypeScript glob怎么用?TypeScript glob使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了glob函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: RegExp
}
tl.debug(`sourcePath: [${sourcePath}]`);
tl.debug(`filePattern: [${filePattern}]`);
tl.debug(`tokenRegex: [${tokenRegex}]`);
if (filePattern === undefined || filePattern.length === 0){
filePattern = "*.*";
}
tl.debug(`Using [${filePattern}] as filePattern`);
var separator = os.platform() === "win32" ? "\\" : "/";
// create a glob removing any spurious quotes
var globPattern = `${sourcePath}${separator}${filePattern}`.replace(/\"/g,"");
var files = tl.glob(globPattern);
if (files.length === 0) {
tl.error(`Could not find files with glob [${globPattern}]`);
tl.exit(1);
}
for (var i = 0; i < files.length; i++) {
var file = files[i];
console.info(`Starting regex replacement in [${file}]`);
var contents = fs.readFileSync(file, 'utf8').toString();
var reg = new RegExp(tokenRegex, "g");
// loop through each match
var match: RegExpExecArray;
while((match = reg.exec(contents)) !== null) {
示例2: RegExp
// get the task vars
var sourcePath = tl.getPathInput("sourcePath", true, true);
var filePattern = tl.getInput("filePattern", true);
var tokenRegex = tl.getInput("tokenRegex", true);
tl.debug(`sourcePath :${sourcePath}`);
tl.debug(`filePattern : ${filePattern}`);
tl.debug(`tokenRegex : ${tokenRegex}`);
if (filePattern === undefined || filePattern.length === 0){
filePattern = "*.*";
}
tl.debug(`Using ${filePattern} as filePattern`);
var files = tl.glob(`${sourcePath}\\${filePattern}`);
if (files.length === 0) {
tl.error(`Could not find files with pattern [${filePattern}] in path [${sourcePath}]`);
tl.exit(1);
}
for (var i = 0; i < files.length; i++) {
var file = files[i];
console.info(`Starting regex replacement in ${file}`);
var contents = fs.readFileSync(file, 'utf8').toString();
var reg = new RegExp(tokenRegex, "g");
// loop through each match
var match: RegExpExecArray;
while((match = reg.exec(contents)) !== null) {