We don't want no node_modules

This commit is contained in:
Michelle Tilley 2016-10-31 16:53:24 -07:00
parent 1bc1b49f84
commit 5c885e6947
No known key found for this signature in database
GPG Key ID: CD86C13E51F378DA
2 changed files with 8 additions and 0 deletions

View File

@ -49,6 +49,7 @@ describe("PackageTranspilationRegistry", () => {
let missPath = '/path/other/file3.js'
let hitPathMissSubdir = '/path/to/file4.js'
let hitPathMissExt = '/path/to/file5.ts'
let nodeModulesFolder = '/path/to/lib/node_modules/file6.js'
let jsSpec = { glob: "lib/**/*.js", transpiler: './transpiler-js', options: { type: 'js' } }
let coffeeSpec = { glob: "*.coffee", transpiler: './transpiler-coffee', options: { type: 'coffee' } }
@ -95,6 +96,7 @@ describe("PackageTranspilationRegistry", () => {
expect(wrappedCompiler.shouldCompile('source', hitPathMissExt)).toBe(false)
expect(wrappedCompiler.shouldCompile('source', hitPathMissSubdir)).toBe(false)
expect(wrappedCompiler.shouldCompile('source', missPath)).toBe(false)
expect(wrappedCompiler.shouldCompile('source', nodeModulesFolder)).toBe(false)
})
it('calls getCacheKeyData on the transpiler to get additional cache key data', () => {
@ -116,6 +118,7 @@ describe("PackageTranspilationRegistry", () => {
expect(wrappedCompiler.compile('source', missPath)).toEqual('source-original-compiler')
expect(wrappedCompiler.compile('source', hitPathMissExt)).toEqual('source-original-compiler')
expect(wrappedCompiler.compile('source', hitPathMissSubdir)).toEqual('source-original-compiler')
expect(wrappedCompiler.compile('source', nodeModulesFolder)).toEqual('source-original-compiler')
})
})
})

View File

@ -65,6 +65,11 @@ Object.assign(PackageTranspilationRegistry.prototype, {
getPackageTranspilerSpecForFilePath: function (filePath) {
if (this.specByFilePath[filePath] !== undefined) return this.specByFilePath[filePath]
// ignore node_modules
if (filePath.indexOf(path.sep + 'node_modules' + path.sep) > -1) {
return false
}
var config = null
var spec = null
var thisPath = filePath