Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 961dc13

Browse files
Jimmyshvsavkin
authored andcommittedFeb 25, 2020
fix(nx-plugin): ignoring Additional Files from Affected Commands (#2519)
* fix(nx-plugin): ignoring Additional Files from Affected Commands ISSUES CLOSED: #2517
1 parent a2e0ed8 commit 961dc13

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
 

‎packages/workspace/src/core/file-utils.spec.ts

+16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { calculateFileChanges, WholeFileChange } from './file-utils';
22
import { DiffType, JsonChange, jsonDiff } from '../utils/json-diff';
33

4+
const ignore = require('ignore');
5+
46
describe('calculateFileChanges', () => {
57
it('should return a whole file change by default', () => {
68
const changes = calculateFileChanges(
@@ -63,4 +65,18 @@ describe('calculateFileChanges', () => {
6365
}
6466
});
6567
});
68+
69+
it('should ignore *.md changes', () => {
70+
const ig = ignore();
71+
ig.add('*.md');
72+
const changes = calculateFileChanges(
73+
['proj/readme.md'],
74+
undefined,
75+
(path, revision) => {
76+
return revision === 'sha1' ? '' : 'const a = 0;';
77+
},
78+
ig
79+
);
80+
expect(changes.length).toEqual(0);
81+
});
6682
});

‎packages/workspace/src/core/file-utils.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ export function calculateFileChanges(
4141
readFileAtRevision: (
4242
f: string,
4343
r: void | string
44-
) => string = defaultReadFileAtRevision
44+
) => string = defaultReadFileAtRevision,
45+
ignore = getIgnoredGlobs()
4546
): FileChange[] {
47+
if (ignore) {
48+
files = files.filter(f => !ignore.ignores(f));
49+
}
4650
return files.map(f => {
4751
const ext = extname(f);
4852
const _mtime = mtime(`${appRootPath}/${f}`);

0 commit comments

Comments
 (0)
Please sign in to comment.