feat(install): use the spec for temp dir name

It is easier to debug when the directory names are
meaningful in the `.tmp` dir.

PR #335
This commit is contained in:
Zoltan Kochan committed 2016-08-31 11:26:11 +03:00
1 parent 1b82eecc67
commit bfb76a5caf
2 files changed
+9 -3

No files matched your search

+8 -2
View File
@@ -1,12 +1,12 @@
'use strict'
const debug = require('debug')('pnpm:install')
const npa = require('npm-package-arg')
const getUuid = require('node-uuid')
const fs = require('mz/fs')
const thenify = require('thenify')
const lock = thenify(require('lockfile').lock)
const unlock = thenify(require('lockfile').unlock)
const checkLock = thenify(require('lockfile').unlock)
const sanitizeFilename = require('sanitize-filename')
const join = require('path').join
const dirname = require('path').dirname
@@ -85,7 +85,7 @@ module.exports = function install (ctx, pkgSpec, modules, options) {
modules,
// Temporary destination while building
tmp: join(ctx.store, '..', '.tmp', getUuid()),
tmp: join(ctx.store, '..', '.tmp', toUniqueDirname(pkgSpec)),
// Final destination => store + '/lodash@4.0.0'
target: undefined
@@ -152,6 +152,12 @@ module.exports = function install (ctx, pkgSpec, modules, options) {
}
}
function toUniqueDirname (pkgSpec) {
// just in case the dirname won't be unique after sanitization
const uid = Number(new Date())
return `${uid}_${sanitizeFilename(pkgSpec, { replacement: '+' })}`
}
/*
* Builds to `.store/lodash@4.0.0` (paths.target)
* If an ongoing build is already working, use it. Also, if that ongoing build
+1 -1
View File
@@ -30,7 +30,6 @@
"mkdirp": "0.5.1",
"mz": "2.4.0",
"node-gyp": "3.4.0",
"node-uuid": "1.4.7",
"normalize-path": "2.0.1",
"npm-package-arg": "4.2.0",
"observatory": "1.0.0",
@@ -41,6 +40,7 @@
"registry-url": "3.1.0",
"retry": "0.10.0",
"rimraf": "2.5.4",
"sanitize-filename": "1.6.0",
"semver": "5.3.0",
"sorted-object": "2.0.0",
"supports-color": "3.1.2",