Skip to content

Commit

Permalink
fix() ignore vim swap files
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Sep 18, 2019
1 parent 0e73c1f commit 8c9c6f4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestjs/schematics",
"version": "6.4.4",
"version": "6.4.5",
"description": "Nest - modern, fast, powerful node.js web framework (@schematics)",
"main": "index.js",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/module.finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ModuleFinder {
return null;
}
const moduleFilename: PathFragment = directory.subfiles.find(filename =>
/\.module\.(t|j)s/.test(filename),
/\.module\.(t|j)s$/.test(filename),
);
return moduleFilename !== undefined
? join(directory.path, moduleFilename.valueOf())
Expand Down
28 changes: 18 additions & 10 deletions test/utils/module.finder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ describe('Module Finder', () => {
const finder = new ModuleFinder(tree);
const options: FindOptions = {
name: 'foo',
path: normalize('/src')
path: normalize('/src'),
};
expect(finder.find(options))
.toEqual(normalize('/src/app.module.ts'));
expect(finder.find(options)).toEqual(normalize('/src/app.module.ts'));
});
it('should return the intermediate module path', () => {
const tree = new EmptyTree();
Expand All @@ -21,21 +20,19 @@ describe('Module Finder', () => {
const finder = new ModuleFinder(tree);
const options: FindOptions = {
name: 'name',
path: normalize('/src/foo')
path: normalize('/src/foo'),
};
expect(finder.find(options))
.toEqual(normalize('/src/foo/foo.module.ts'));
expect(finder.find(options)).toEqual(normalize('/src/foo/foo.module.ts'));
});
it('should manage javascript module file', () => {
const tree = new EmptyTree();
tree.create('/src/app.module.js', 'app module content');
const finder = new ModuleFinder(tree);
const options: FindOptions = {
name: 'foo',
path: normalize('/src')
path: normalize('/src'),
};
expect(finder.find(options))
.toEqual(normalize('/src/app.module.js'));
expect(finder.find(options)).toEqual(normalize('/src/app.module.js'));
});

it('should return null when directory does not exist', () => {
Expand All @@ -44,7 +41,18 @@ describe('Module Finder', () => {
const finder = new ModuleFinder(tree);
const options: FindOptions = {
name: 'foo',
path: normalize('/src')
path: normalize('/src'),
};
expect(finder.find(options)).toEqual(null);
});

it('should ignore vim swap files', () => {
const tree = new EmptyTree();
tree.create('/src/foo/foo.module.ts.swp', 'foo module content');
const finder = new ModuleFinder(tree);
const options: FindOptions = {
name: 'name',
path: normalize('/src/foo'),
};
expect(finder.find(options)).toEqual(null);
});
Expand Down

0 comments on commit 8c9c6f4

Please sign in to comment.