本文整理匯總了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;
};