This repository has been archived by the owner on Aug 11, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
child-path: Compute the path of a new child module in only one place
PR-URL: //github.com//pull/9890 Fixes: #9766
- Loading branch information
Showing
5 changed files
with
27 additions
and
8 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
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,10 @@ | ||
'use strict' | ||
var path = require('path') | ||
var validate = require('aproba') | ||
var moduleName = require('../utils/module-name.js') | ||
|
||
module.exports = childPath | ||
function childPath (parentPath, child) { | ||
validate('SO', arguments) | ||
return path.join(parentPath, 'node_modules', moduleName(child)) | ||
} |
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,9 @@ | ||
'use strict' | ||
var test = require('tap').test | ||
var childPath = require('../../lib/utils/child-path.js') | ||
|
||
test('childPath', function (t) { | ||
t.is(childPath('/path/to', {name: 'abc'}), '/path/to/node_modules/abc', 'basic use') | ||
t.is(childPath('/path/to', {package: {name: '@zed/abc'}}), '/path/to/node_modules/@zed/abc', 'scoped use') | ||
t.end() | ||
}) |