Skip to content

Commit

Permalink
bugfix: #886
Browse files Browse the repository at this point in the history
  • Loading branch information
mplewis committed Jul 9, 2017
1 parent c9dd91d commit dbc9ec7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/core/importType.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export function isAbsolute(name) {
}

export function isBuiltIn(name, settings) {
const baseModule = name.split('/')[0]
const extras = (settings && settings['import/core-modules']) || []
return builtinModules.indexOf(name) !== -1 || extras.indexOf(name) > -1
return builtinModules.indexOf(baseModule) !== -1 || extras.indexOf(baseModule) > -1
}

function isExternalPath(path, name, settings) {
Expand Down
7 changes: 6 additions & 1 deletion tests/src/core/importType.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import importType from 'core/importType'

import { testContext } from '../utils'

describe('importType(name)', function () {
describe.only('importType(name)', function () {
const context = testContext()

it("should return 'absolute' for paths starting with a /", function() {
Expand Down Expand Up @@ -74,6 +74,11 @@ describe('importType(name)', function () {
expect(importType('electron', electronContext)).to.equal('builtin')
})

it("should return 'builtin' for resources inside additional core modules", function() {
const electronContext = testContext({ 'import/core-modules': ['electron'] })
expect(importType('electron/some/path/to/resource.json', electronContext)).to.equal('builtin')
})

it("should return 'external' for module from 'node_modules' with default config", function() {
expect(importType('builtin-modules', context)).to.equal('external')
})
Expand Down

0 comments on commit dbc9ec7

Please sign in to comment.