Merge pull request #23322 from atom/install-using-npm-in-script

Install using npm installed during installation of script dependencies
This commit is contained in:
Sadick 2021-12-03 17:38:19 +03:00 committed by GitHub
commit 7033a5a22f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 28 deletions

View File

@ -3,7 +3,6 @@
'use strict';
const fs = require('fs');
const path = require('path');
const spawnSync = require('./lib/spawn-sync');
@ -113,8 +112,6 @@ function getApmBinPath() {
}
function getNpmBinPath(external = false) {
if (process.env.NPM_BIN_PATH) return process.env.NPM_BIN_PATH;
const npmBinName = process.platform === 'win32' ? 'npm.cmd' : 'npm';
const localNpmBinPath = path.resolve(
repositoryRootPath,
@ -123,7 +120,5 @@ function getNpmBinPath(external = false) {
'.bin',
npmBinName
);
return !external && fs.existsSync(localNpmBinPath)
? localNpmBinPath
: npmBinName;
return localNpmBinPath;
}

View File

@ -9,8 +9,9 @@ process.env.ELECTRON_CUSTOM_VERSION = CONFIG.appMetadata.electronVersion;
module.exports = function(ci) {
console.log('Installing script dependencies');
const npmBinName = process.platform === 'win32' ? 'npm.cmd' : 'npm';
childProcess.execFileSync(
CONFIG.getNpmBinPath(ci),
npmBinName,
['--loglevel=error', ci ? 'ci' : 'install'],
{ env: process.env, cwd: CONFIG.scriptRootPath }
);

View File

@ -3,11 +3,8 @@
const childProcess = require('child_process');
const path = require('path');
const CONFIG = require('../config');
module.exports = function(ci) {
verifyNode();
verifyNpm(ci);
verifyPython();
};
@ -24,24 +21,6 @@ function verifyNode() {
}
}
function verifyNpm(ci) {
const stdout = childProcess.execFileSync(
CONFIG.getNpmBinPath(ci),
['--version'],
{ env: process.env }
);
const fullVersion = stdout.toString().trim();
const majorVersion = fullVersion.split('.')[0];
const oldestMajorVersionSupported = ci ? 6 : 3;
if (majorVersion >= oldestMajorVersionSupported) {
console.log(`Npm:\tv${fullVersion}`);
} else {
throw new Error(
`npm v${oldestMajorVersionSupported}+ is required to build Atom. npm v${fullVersion} was detected.`
);
}
}
function verifyPython() {
// This function essentially re-implements node-gyp's "find-python.js" library,
// but in a synchronous, bootstrap-script-friendly way.