-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pacote now optionally takes a tree when preparing directories
If a tree is not passed in, then pacote will create one with `loadActual` and the resolved path to the directory it is preparing. BREAKING CHANGE: `pacote` now has a peer dependency on `@npmcli/arborist`.
- Loading branch information
1 parent
c3289af
commit d3517fd
Showing
6 changed files
with
101 additions
and
66 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
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,28 @@ | ||
#!/usr/bin/env node | ||
const { argv, env } = process | ||
|
||
const pnp = env._PACOTE_NO_PREPARE_ || '' | ||
const pacotePath = env._PACOTE_TEST_PATH_ | ||
const pacoteOpts = env._PACOTE_TEST_OPTS_ | ||
|
||
const data = { | ||
argv, | ||
noPrepare: pnp ? pnp.split('\\n') : [], | ||
cwd: process.cwd(), | ||
} | ||
|
||
if (data.noPrepare.length > 5) { | ||
throw new Error('infinite regress detected!') | ||
} | ||
|
||
// just an incredibly rudimentary package manager | ||
const pkg = require(process.cwd() + '/package.json') | ||
const pacote = require(pacotePath) | ||
for (const [name, spec] of Object.entries(pkg.dependencies)) { | ||
pacote.extract(spec, process.cwd() + '/' + name, { | ||
npmBin: __filename, | ||
...JSON.parse(pacoteOpts), | ||
}) | ||
} | ||
|
||
require('fs').writeFileSync('log', JSON.stringify(data, 0, 2)) |
Oops, something went wrong.