-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ignore hidden and non .js files in loader (#113)
* fix: ignore hidden and non .js files in loader (#110) * style: renaming variables for consistentcy * refactor: export `isJSFile` helper straight from `fs` package * refactor: import isJSFile from fs instead
- Loading branch information
1 parent
6d97ca7
commit 1b84009
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// filter out hidden files && non .js files | ||
export default function isJSFile(file) { | ||
return /^(?!\.).+\.js$/.test(file); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { expect } from 'chai'; | ||
|
||
import { isJSFile } from '../../../src/packages/fs'; | ||
|
||
describe('Unit: class fs ', () => { | ||
describe('Unit: util isJSFile', () => { | ||
const subject = { | ||
a: 'author.js', | ||
b: '.gitkeep', | ||
c: 'author.js~' | ||
}; | ||
|
||
it('is a JavaScript file', () => { | ||
const result = isJSFile(subject.a); | ||
|
||
expect(result).to.be.a('boolean'); | ||
expect(result).to.equal(true); | ||
}); | ||
|
||
it('filter out hidden files', () => { | ||
const result = isJSFile(subject.b); | ||
|
||
expect(result).to.be.a('boolean'); | ||
expect(result).to.equal(false); | ||
}); | ||
|
||
it('filter out non JavaScript files', () => { | ||
const result = isJSFile(subject.c); | ||
|
||
expect(result).to.be.a('boolean'); | ||
expect(result).to.equal(false); | ||
}); | ||
}); | ||
}); |