-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to require module path from whitelisted dependency
Required module path can be one of - `fs` (built-in Node.js module), - `abortcontroller-polyfill` (external main module), - `abortcontroller-polyfill/dist/cjs-ponyfill` (external submodule). FastBoot's build system requires only dependency whitelisting, thus looking only for the first part of module path.
- Loading branch information
Showing
5 changed files
with
51 additions
and
14 deletions.
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
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,12 @@ | ||
'use strict'; | ||
|
||
function getPackageName(modulePath) { | ||
let parts = modulePath.split('/'); | ||
|
||
if (modulePath[0] === '@') { | ||
return parts[0] + '/' + parts[1]; | ||
} | ||
return parts[0]; | ||
} | ||
|
||
module.exports = getPackageName; |
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,12 @@ | ||
'use strict'; | ||
const expect = require('chai').expect; | ||
const getPackageName = require('../src/utils/get-package-name'); | ||
|
||
describe('utils/get-package-name', function() { | ||
it('gets package name from module path', function() { | ||
expect(getPackageName('foo')).to.equal('foo'); | ||
expect(getPackageName('foo/bar')).to.equal('foo'); | ||
expect(getPackageName('@foo/baz')).to.equal('@foo/baz'); | ||
expect(getPackageName('@foo/baz/bar')).to.equal('@foo/baz'); | ||
}); | ||
}); |