Skip to content

Commit 66694e2

Browse files
targosMylesBorins
authored andcommitted
tools: fix test-npm-package
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]>
1 parent f36521b commit 66694e2

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tools/test-npm-package.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const { createWriteStream, mkdirSync, rmdirSync } = require('fs');
2222
const path = require('path');
2323

2424
const common = require('../test/common');
25+
const tmpDir = require('../test/common/tmpdir');
2526

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

45-
const tmpDir = common.tmpDir;
46-
const npmCache = path.join(tmpDir, 'npm-cache');
47-
const npmPrefix = path.join(tmpDir, 'npm-prefix');
48-
const npmTmp = path.join(tmpDir, 'npm-tmp');
49-
const npmUserconfig = path.join(tmpDir, 'npm-userconfig');
50-
const pkgDir = path.join(tmpDir, 'pkg');
46+
const npmCache = path.join(tmpDir.path, 'npm-cache');
47+
const npmPrefix = path.join(tmpDir.path, 'npm-prefix');
48+
const npmTmp = path.join(tmpDir.path, 'npm-tmp');
49+
const npmUserconfig = path.join(tmpDir.path, 'npm-userconfig');
50+
const pkgDir = path.join(tmpDir.path, 'pkg');
5151

5252
spawnCopyDeepSync(srcDir, pkgDir);
5353

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

6565
if (common.isWindows) {
66-
npmOptions.env.home = tmpDir;
66+
npmOptions.env.home = tmpDir.path;
6767
npmOptions.env.Path = `${nodePath};${process.env.Path}`;
6868
} else {
69-
npmOptions.env.HOME = tmpDir;
69+
npmOptions.env.HOME = tmpDir.path;
7070
npmOptions.env.PATH = `${nodePath}:${process.env.PATH}`;
7171
}
7272

@@ -102,8 +102,8 @@ function runNPMPackageTests({ srcDir, install, rebuild, testArgs, logfile }) {
102102
}
103103

104104
testChild.on('exit', () => {
105-
common.refreshTmpDir();
106-
rmdirSync(tmpDir);
105+
tmpDir.refresh();
106+
rmdirSync(tmpDir.path);
107107
});
108108
}
109109

0 commit comments

Comments
 (0)