Skip to content

Commit

Permalink
tools: fix test-npm-package
Browse files Browse the repository at this point in the history
Migrate the script to the new common tmpDir API.

PR-URL: #19293
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Myles Borins <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
  • Loading branch information
targos authored and MylesBorins committed Mar 20, 2018
1 parent f36521b commit 66694e2
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tools/test-npm-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const { createWriteStream, mkdirSync, rmdirSync } = require('fs');
const path = require('path');

const common = require('../test/common');
const tmpDir = require('../test/common/tmpdir');

const projectDir = path.resolve(__dirname, '..');
const npmBin = path.join(projectDir, 'deps', 'npm', 'bin', 'npm-cli.js');
Expand All @@ -39,15 +40,14 @@ function spawnCopyDeepSync(source, destination) {
function runNPMPackageTests({ srcDir, install, rebuild, testArgs, logfile }) {
// Make sure we don't conflict with concurrent test runs
const srcHash = createHash('md5').update(srcDir).digest('hex');
common.tmpDir = `${common.tmpDir}.npm.${srcHash}`;
common.refreshTmpDir();
tmpDir.path = `${tmpDir.path}.npm.${srcHash}`;
tmpDir.refresh();

const tmpDir = common.tmpDir;
const npmCache = path.join(tmpDir, 'npm-cache');
const npmPrefix = path.join(tmpDir, 'npm-prefix');
const npmTmp = path.join(tmpDir, 'npm-tmp');
const npmUserconfig = path.join(tmpDir, 'npm-userconfig');
const pkgDir = path.join(tmpDir, 'pkg');
const npmCache = path.join(tmpDir.path, 'npm-cache');
const npmPrefix = path.join(tmpDir.path, 'npm-prefix');
const npmTmp = path.join(tmpDir.path, 'npm-tmp');
const npmUserconfig = path.join(tmpDir.path, 'npm-userconfig');
const pkgDir = path.join(tmpDir.path, 'pkg');

spawnCopyDeepSync(srcDir, pkgDir);

Expand All @@ -63,10 +63,10 @@ function runNPMPackageTests({ srcDir, install, rebuild, testArgs, logfile }) {
};

if (common.isWindows) {
npmOptions.env.home = tmpDir;
npmOptions.env.home = tmpDir.path;
npmOptions.env.Path = `${nodePath};${process.env.Path}`;
} else {
npmOptions.env.HOME = tmpDir;
npmOptions.env.HOME = tmpDir.path;
npmOptions.env.PATH = `${nodePath}:${process.env.PATH}`;
}

Expand Down Expand Up @@ -102,8 +102,8 @@ function runNPMPackageTests({ srcDir, install, rebuild, testArgs, logfile }) {
}

testChild.on('exit', () => {
common.refreshTmpDir();
rmdirSync(tmpDir);
tmpDir.refresh();
rmdirSync(tmpDir.path);
});
}

Expand Down

0 comments on commit 66694e2

Please sign in to comment.