Instead of writing the fixtures on the fly in the test, put them in the fixtures directory that can be copied into a temporary directory to reproduce in a debugger. Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com> PR-URL: https://github.com/nodejs/node/pull/62584 Refs: https://github.com/nodejs/node/pull/61898 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
if (common.isInsideDirWithUnusualChars)
|
|
common.skip('npm does not support this install path');
|
|
|
|
const path = require('path');
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const fixtures = require('../common/fixtures');
|
|
const { spawnSyncAndAssert } = require('../common/child_process');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
|
|
// Copy fixtures/npm-install to the tmpdir for testing
|
|
fs.cpSync(fixtures.path('npm-install'), tmpdir.path, { recursive: true });
|
|
|
|
const npmPath = path.join(__dirname, '..', '..', 'deps', 'npm', 'bin', 'npm-cli.js');
|
|
|
|
const env = {
|
|
...process.env,
|
|
PATH: path.dirname(process.execPath),
|
|
NODE: process.execPath,
|
|
NPM: npmPath,
|
|
NPM_CONFIG_PREFIX: tmpdir.resolve('npm-prefix'),
|
|
NPM_CONFIG_TMP: tmpdir.resolve('npm-tmp'),
|
|
NPM_CONFIG_AUDIT: false,
|
|
NPM_CONFIG_UPDATE_NOTIFIER: false,
|
|
HOME: tmpdir.resolve('home'),
|
|
};
|
|
|
|
const installDir = tmpdir.resolve('install-dir');
|
|
spawnSyncAndAssert(
|
|
process.execPath,
|
|
[npmPath, 'install'],
|
|
{ cwd: installDir, env },
|
|
{}
|
|
);
|
|
|
|
assert(fs.existsSync(path.join(installDir, 'node_modules', 'example')));
|