From bfb76a5caff3ecc300e4aca3d0ef5b1c16189dff Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Wed, 31 Aug 2016 00:09:56 +0300 Subject: [PATCH] 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 --- lib/install.js | 10 ++++++++-- package.json | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/install.js b/lib/install.js index c7d8fdf033..46e07a9904 100644 --- a/lib/install.js +++ b/lib/install.js @@ -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 diff --git a/package.json b/package.json index 77beb7b9f4..1b947c0190 100644 --- a/package.json +++ b/package.json @@ -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",