-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add _from, _resolved back to package.json
closes #42
- Loading branch information
Showing
8 changed files
with
103 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,27 +139,27 @@ Two rules: | |
|
||
e.g.: | ||
|
||
- app: `{ "dependencies": { "debug": "2.2.0", "ms": "0.5.1" } }` (root) | ||
- app: `{ "dependencies": { "debug": "2.2.0" } }` (root) | ||
- [email protected]: `{ "dependencies": { "ms": "0.7.1" } }` | ||
|
||
```bash | ||
app/ | ||
├── package.json | ||
└── node_modules/ | ||
├── .npminstall/ | ||
│ ├── debug/ | ||
│ │ └── 2.2.0/ | ||
│ │ └── debug/ | ||
│ │ └── node_modules/ | ||
│ │ └── debug | ||
│ │ ├── package.json | ||
│ │ └── node_modules/ | ||
│ │ └── ms -> ../../../../ms/0.7.1/ms | ||
│ ├── ms/ | ||
│ │ ├── 0.5.1/ | ||
│ │ │ └── ms/ | ||
│ │ └── 0.7.1/ | ||
│ │ └── ms/ | ||
│ │ └── ms | ||
│ │ └── package.json | ||
│ └── node_modules/ | ||
│ └── ms -> ../ms/0.7.1/ms | ||
├── debug -> .npminstall/debug/2.2.0/debug | ||
└── ms -> .npminstall/ms/0.5.1/ms | ||
└── debug -> .npminstall/debug/2.2.0/debug | ||
``` | ||
|
||
`[email protected]` is root package, won't create link at `app/node_modules/.npminstall/node_modules/debug@`. | ||
|
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
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,9 @@ | ||
{ | ||
"name": "packageMeta", | ||
"dependencies": { | ||
"debug": "2.2.0", | ||
"a": "*", | ||
"pedding": "http://registry.cnpmjs.org/pedding/download/pedding-1.0.0.tgz", | ||
"bytes": "https://github.com/visionmedia/bytes.js.git" | ||
} | ||
} |
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 |
---|---|---|
|
@@ -98,4 +98,43 @@ describe('test/index.test.js', function() { | |
const v1 = yield readJSON(path.join(tmp, 'node_modules', 'pedding', 'package.json')); | ||
assert.equal(v1.version[0], '1'); | ||
}); | ||
|
||
describe('_from, _resolved in package.json', function() { | ||
const root = path.join(__dirname, 'fixtures', 'packageMeta'); | ||
|
||
function cleanup() { | ||
rimraf.sync(path.join(root, 'node_modules')); | ||
} | ||
|
||
beforeEach(cleanup); | ||
afterEach(cleanup); | ||
|
||
it('should add _from, _resolved to package.json', function*() { | ||
yield npminstall({ | ||
root: root, | ||
}); | ||
// node_modules/.npminstall/node_modules/ms should exists | ||
assert(yield fs.exists(path.join(root, 'node_modules', '.npminstall', 'node_modules', 'ms'))); | ||
// node_modules/.npminstall/node_modules/debug should not exists | ||
assert(!(yield fs.exists(path.join(root, 'node_modules', '.npminstall', 'node_modules', 'debug')))); | ||
assert(yield fs.exists(path.join(root, 'node_modules', 'pedding'))); | ||
|
||
const debugPkg = yield readJSON(path.join(root, 'node_modules', 'debug', 'package.json')); | ||
assert.equal(debugPkg._from, '[email protected]'); | ||
assert(debugPkg._resolved); | ||
|
||
const aPkg = yield readJSON(path.join(root, 'node_modules', 'a', 'package.json')); | ||
assert(/^a@\d+\.\d+\.\d+$/.test(aPkg._from), aPkg._from); | ||
assert(aPkg._resolved); | ||
|
||
const peddingPkg = yield readJSON(path.join(root, 'node_modules', 'pedding', 'package.json')); | ||
assert.equal(peddingPkg._from, 'pedding@http://registry.cnpmjs.org/pedding/download/pedding-1.0.0.tgz'); | ||
assert.equal(peddingPkg._resolved, 'http://registry.cnpmjs.org/pedding/download/pedding-1.0.0.tgz'); | ||
|
||
const bytesPkg = yield readJSON(path.join(root, 'node_modules', 'bytes', 'package.json')); | ||
assert.equal(bytesPkg._from, 'bytes@https://github.com/visionmedia/bytes.js.git'); | ||
assert(/^https:\/\/github\.com\/visionmedia\/bytes\.js\.git#\w{40}$/.test(bytesPkg._resolved), bytesPkg._resolved); | ||
}); | ||
}); | ||
|
||
}); |