fix(nx-plugin): ignoring Additional Files from Affected Commands (#2519)
* fix(nx-plugin): ignoring Additional Files from Affected Commands ISSUES CLOSED: #2517
This commit is contained in:
parent
74716df4fc
commit
06b0e7fe6e
@ -1,6 +1,8 @@
|
||||
import { calculateFileChanges, WholeFileChange } from './file-utils';
|
||||
import { DiffType, JsonChange, jsonDiff } from '../utils/json-diff';
|
||||
|
||||
const ignore = require('ignore');
|
||||
|
||||
describe('calculateFileChanges', () => {
|
||||
it('should return a whole file change by default', () => {
|
||||
const changes = calculateFileChanges(
|
||||
@ -63,4 +65,18 @@ describe('calculateFileChanges', () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should ignore *.md changes', () => {
|
||||
const ig = ignore();
|
||||
ig.add('*.md');
|
||||
const changes = calculateFileChanges(
|
||||
['proj/readme.md'],
|
||||
undefined,
|
||||
(path, revision) => {
|
||||
return revision === 'sha1' ? '' : 'const a = 0;';
|
||||
},
|
||||
ig
|
||||
);
|
||||
expect(changes.length).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
@ -41,8 +41,12 @@ export function calculateFileChanges(
|
||||
readFileAtRevision: (
|
||||
f: string,
|
||||
r: void | string
|
||||
) => string = defaultReadFileAtRevision
|
||||
) => string = defaultReadFileAtRevision,
|
||||
ignore = getIgnoredGlobs()
|
||||
): FileChange[] {
|
||||
if (ignore) {
|
||||
files = files.filter(f => !ignore.ignores(f));
|
||||
}
|
||||
return files.map(f => {
|
||||
const ext = extname(f);
|
||||
const _mtime = mtime(`${appRootPath}/${f}`);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user