本文整理汇总了TypeScript中jest-changed-files.getChangedFilesForRoots函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getChangedFilesForRoots函数的具体用法?TypeScript getChangedFilesForRoots怎么用?TypeScript getChangedFilesForRoots使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getChangedFilesForRoots函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('monitors only root paths for hg', async () => {
if (process.env.CI) {
// Circle and Travis have very old version of hg (v2, and current
// version is v4.2) and its API changed since then and not compatible
// any more. Changing the SCM version on CIs is not trivial, so we'll just
// skip this test and run it only locally.
return;
}
writeFiles(DIR, {
'file1.txt': 'file1',
'nested-dir/file2.txt': 'file2',
'nested-dir/second-nested-dir/file3.txt': 'file3',
});
run(`${HG} init`, DIR);
const roots = [path.resolve(DIR, 'nested-dir')];
const {changedFiles: files} = await getChangedFilesForRoots(roots, {});
expect(
Array.from(files)
.map(filePath => path.basename(filePath))
.sort(),
).toEqual(['file2.txt', 'file3.txt']);
});
示例2: default
export default (
globalConfig: Config.GlobalConfig,
configs: Array<Config.ProjectConfig>,
): ChangedFilesPromise | undefined => {
if (globalConfig.onlyChanged) {
const allRootsForAllProjects = configs.reduce<Array<Config.Path>>(
(roots, config) => [...roots, ...(config.roots || [])],
[],
);
return getChangedFilesForRoots(allRootsForAllProjects, {
changedSince: globalConfig.changedSince,
lastCommit: globalConfig.lastCommit,
withAncestor: globalConfig.changedFilesWithAncestor,
}).catch(e => {
const message = formatExecError(e, configs[0], {noStackTrace: true})
.split('\n')
.filter(line => !line.includes('Command failed:'))
.join('\n');
console.error(chalk.red(`\n\n${message}`));
process.exit(1);
// We do process.exit, so this is dead code
return Promise.reject(e);
});
}
return undefined;
};