本文整理匯總了TypeScript中minimatch.match函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript match函數的具體用法?TypeScript match怎麽用?TypeScript match使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了match函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getTypescriptSpecs
function getTypescriptSpecs(packageSpecs: ProjectBuildPackageSpecs): ProjectBuildPackageTypescriptSpecs {
var typescriptFiles = minimatch.match(packageSpecs.files, "**/*.ts");
var typescriptConfigs = minimatch.match(packageSpecs.files, "**/tsconfig.json");
var typingConfig = minimatch.match(packageSpecs.files, "typings.json");
if(_.isEmpty(typescriptFiles) && _.isEmpty(typescriptConfigs)) {
return null;
}
return {
files: typescriptFiles,
configs: typescriptConfigs,
typingsConfig: _.isEmpty(typingConfig) ? null : _.first(typingConfig)
};
}
示例2: getPackages
function getPackages(files: string[]) {
var packages = minimatch.match(files, "**/package.json");
if (packages.length) {
return packages;
} else {
return null;
}
}
示例3: getUnitTestsSpecs
function getUnitTestsSpecs(packageSpecs: ProjectBuildPackageSpecs): ProjectBuildPackageUnitTestsSpecs {
var unitTestsFiles = minimatch.match(packageSpecs.files, "**/*.spec.*");
if(_.isEmpty(unitTestsFiles)) {
return null;
}
return {
files: unitTestsFiles
};
}
示例4: getPackageSpecs
function getPackageSpecs(packageFile: string, projectFiles: string[]) : ProjectBuildPackageSpecs {
if (packageFile) {
var packageRootPath = path.dirname(packageFile);
return {
npm: {
file: packageFile,
missing: false
},
files: minimatch.match(projectFiles, packageRootPath + "**/*")
};
} else {
return {
npm: {
file: null,
missing: true
},
files: projectFiles
};
}
}
示例5: applyFilter
function applyFilter(files: string[], filters?: string[] | string) {
if (!filters) {
return files;
} else if (_.isString(filters)){
return minimatch.match(files, filters, { matchBase: true });
} else {
var tests = _.map(filters, filter => minimatch.makeRe(filter, { matchBase: true }));
return _.filter(files, file => {
var result = true;
_.forEach(tests, regex => {
if(!regex.test(file)) {
result = false;
return false;
}
});
return result;
});
}
}