Skip to content

Commit

Permalink
fix: pick fix parallel install from local directory (#398) (#412) (#…
Browse files Browse the repository at this point in the history
…421)

* fix: fix parallel install from local directory (#398)

* fix: parallel install from local directory

Co-authored-by: Yiyu He <dead_horse@qq.com>

Co-authored-by: Yiyu He <dead_horse@qq.com>
  • Loading branch information
vagusX and dead-horse committed Oct 17, 2022
1 parent 1d7fbae commit 8170ce2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/download/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ module.exports = async (pkg, options) => {
async function localFolder(filepath, pkg, options) {
debug(`install ${pkg.name}@${pkg.rawSpec} from local folder ${filepath}`);
try {
// everytime copy to a different directory to avoid parallel install
const tmpDir = path.join(options.storeDir, '.tmp', randomUUID());
await utils.mkdirp(tmpDir);
// use npm pack to ensure npmignore/gitignore/package.files work fine
const res = await utils.exec('npm pack', { cwd: filepath });
const res = await utils.exec(`npm pack --pack-destination ${tmpDir}`, { cwd: filepath });
if (res && res.stdout) {
const tarball = path.join(filepath, res.stdout.trim());
const tarball = path.join(tmpDir, res.stdout.trim());
try {
return await localTarball(tarball, pkg, options);
} finally {
Expand Down

0 comments on commit 8170ce2

Please sign in to comment.