Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #23322 from atom/install-using-npm-in-script
Browse files Browse the repository at this point in the history
Install using npm installed during installation of script dependencies
  • Loading branch information
sadick254 committed Dec 3, 2021
2 parents eb6258f + 309ecff commit 7033a5a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 28 deletions.
7 changes: 1 addition & 6 deletions script/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

'use strict';

const fs = require('fs');
const path = require('path');
const spawnSync = require('./lib/spawn-sync');

Expand Down Expand Up @@ -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,
Expand All @@ -123,7 +120,5 @@ function getNpmBinPath(external = false) {
'.bin',
npmBinName
);
return !external && fs.existsSync(localNpmBinPath)
? localNpmBinPath
: npmBinName;
return localNpmBinPath;
}
3 changes: 2 additions & 1 deletion script/lib/install-script-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
);
Expand Down
21 changes: 0 additions & 21 deletions script/lib/verify-machine-requirements.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

Expand All @@ -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.
Expand Down

0 comments on commit 7033a5a

Please sign in to comment.