Skip to content

Commit

Permalink
fix(nx-plugin): ignoring Additional Files from Affected Commands (#2519)
Browse files Browse the repository at this point in the history
* fix(nx-plugin): ignoring Additional Files from Affected Commands

ISSUES CLOSED: #2517
  • Loading branch information
Jimmysh authored and vsavkin committed Feb 25, 2020
1 parent a2e0ed8 commit 961dc13
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
16 changes: 16 additions & 0 deletions packages/workspace/src/core/file-utils.spec.ts
@@ -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(
Expand Down Expand Up @@ -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);
});
});
6 changes: 5 additions & 1 deletion packages/workspace/src/core/file-utils.ts
Expand Up @@ -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}`);
Expand Down

0 comments on commit 961dc13

Please sign in to comment.