本文整理匯總了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) {