本文整理汇总了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;
});
}
}