Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaël Nison <nison.mael@gmail.com>2020-09-28 18:35:09 +0300
committerRichard Lau <rlau@redhat.com>2022-01-25 18:48:47 +0300
commit737df75e1707b41c30b71d94c779abe665edef41 (patch)
tree97e1b0ef62c9d896b23c461c44c74039dd3c88a5 /test/parallel
parentb85aa5a1438857d82f49c1a2f458e86a21c1460c (diff)
deps: add corepack
Corepack provides shims for Yarn and pnpm in order to soften the developer experience when working on Node projects. Refs: https://github.com/nodejs/node/issues/15244 Refs: https://github.com/nodejs/TSC/issues/904 PR-URL: https://github.com/nodejs/node/pull/39608 Backport-PR-URL: https://github.com/nodejs/node/pull/40479 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'test/parallel')
-rw-r--r--test/parallel/test-corepack-version.js18
-rw-r--r--test/parallel/test-corepack-yarn-install.js63
2 files changed, 81 insertions, 0 deletions
diff --git a/test/parallel/test-corepack-version.js b/test/parallel/test-corepack-version.js
new file mode 100644
index 00000000000..9009edd2b9e
--- /dev/null
+++ b/test/parallel/test-corepack-version.js
@@ -0,0 +1,18 @@
+'use strict';
+require('../common');
+
+const path = require('path');
+const assert = require('assert');
+
+const corepackPathPackageJson = path.resolve(
+ __dirname,
+ '..',
+ '..',
+ 'deps',
+ 'corepack',
+ 'package.json'
+);
+
+const pkg = require(corepackPathPackageJson);
+assert(pkg.version.match(/^\d+\.\d+\.\d+$/),
+ `unexpected version number: ${pkg.version}`);
diff --git a/test/parallel/test-corepack-yarn-install.js b/test/parallel/test-corepack-yarn-install.js
new file mode 100644
index 00000000000..7fe22387bca
--- /dev/null
+++ b/test/parallel/test-corepack-yarn-install.js
@@ -0,0 +1,63 @@
+'use strict';
+const common = require('../common');
+if (!common.hasCrypto)
+ common.skip('missing crypto');
+
+const path = require('path');
+const exec = require('child_process').exec;
+const assert = require('assert');
+const fs = require('fs');
+const fixtures = require('../common/fixtures');
+
+const tmpdir = require('../common/tmpdir');
+tmpdir.refresh();
+const npmSandbox = path.join(tmpdir.path, 'npm-sandbox');
+fs.mkdirSync(npmSandbox);
+const homeDir = path.join(tmpdir.path, 'home');
+fs.mkdirSync(homeDir);
+const installDir = path.join(tmpdir.path, 'install-dir');
+fs.mkdirSync(installDir);
+
+const corepackYarnPath = path.join(
+ __dirname,
+ '..',
+ '..',
+ 'deps',
+ 'corepack',
+ 'dist',
+ 'yarn.js'
+);
+
+const pkgContent = JSON.stringify({
+ dependencies: {
+ 'package-name': fixtures.path('packages/main')
+ }
+});
+
+const pkgPath = path.join(installDir, 'package.json');
+
+fs.writeFileSync(pkgPath, pkgContent);
+
+const env = { ...process.env,
+ PATH: path.dirname(process.execPath),
+ NPM_CONFIG_PREFIX: path.join(npmSandbox, 'npm-prefix'),
+ NPM_CONFIG_TMP: path.join(npmSandbox, 'npm-tmp'),
+ HOME: homeDir };
+
+exec(`${process.execPath} ${corepackYarnPath} install`, {
+ cwd: installDir,
+ env: env
+}, common.mustCall(handleExit));
+
+function handleExit(error, stdout, stderr) {
+ const code = error ? error.code : 0;
+ const signalCode = error ? error.signal : null;
+
+ if (code !== 0) {
+ process.stderr.write(stderr);
+ }
+
+ assert.strictEqual(code, 0, `yarn install got error code ${code}`);
+ assert.strictEqual(signalCode, null, `unexpected signal: ${signalCode}`);
+ assert(fs.existsSync(`${installDir}/node_modules/package-name`));
+}