mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 12:58:19 +02:00
Sync deps and engines with npm (#2770)
* feat!: update `engines.node` to `^14.17.0 || ^16.13.0 || >=18.0.0` * deps: nopt@^7.0.0 * feat: replace npmlog with proc-log * deps: standard@17.0.0 and fix linting errors * deps: which@3.0.0 - this also promiisifies the build command * deps: glob@8.0.3 * feat: drop rimraf dependency * fix: use fs/promises in favor of fs.promises
This commit is contained in:
parent
33391db3a0
commit
192eec2aca
27 changed files with 536 additions and 418 deletions
|
@ -1,11 +1,10 @@
|
|||
'use strict'
|
||||
|
||||
const log = require('npmlog')
|
||||
const log = require('./log')
|
||||
const semver = require('semver')
|
||||
const cp = require('child_process')
|
||||
const extend = require('util')._extend // eslint-disable-line
|
||||
const win = process.platform === 'win32'
|
||||
const logWithPrefix = require('./util').logWithPrefix
|
||||
|
||||
const systemDrive = process.env.SystemDrive || 'C:'
|
||||
const username = process.env.USERNAME || process.env.USER || getOsUserInfo()
|
||||
|
@ -46,7 +45,7 @@ function PythonFinder (configPython, callback) {
|
|||
}
|
||||
|
||||
PythonFinder.prototype = {
|
||||
log: logWithPrefix(log, 'find Python'),
|
||||
log: log.withPrefix('find Python'),
|
||||
argsExecutable: ['-c', 'import sys; print(sys.executable);'],
|
||||
argsVersion: ['-c', 'import sys; print("%s.%s.%s" % sys.version_info[:3]);'],
|
||||
semverRange: '>=3.6.0',
|
||||
|
@ -54,7 +53,7 @@ PythonFinder.prototype = {
|
|||
// These can be overridden for testing:
|
||||
execFile: cp.execFile,
|
||||
env: process.env,
|
||||
win: win,
|
||||
win,
|
||||
pyLauncher: 'py.exe',
|
||||
winDefaultLocations: winDefaultLocationsArray,
|
||||
|
||||
|
@ -69,7 +68,7 @@ PythonFinder.prototype = {
|
|||
// Ignore errors, keep trying until Python is found.
|
||||
findPython: function findPython () {
|
||||
const SKIP = 0; const FAIL = 1
|
||||
var toCheck = getChecks.apply(this)
|
||||
const toCheck = getChecks.apply(this)
|
||||
|
||||
function getChecks () {
|
||||
if (this.env.NODE_GYP_FORCE_PYTHON) {
|
||||
|
@ -85,7 +84,7 @@ PythonFinder.prototype = {
|
|||
}]
|
||||
}
|
||||
|
||||
var checks = [
|
||||
const checks = [
|
||||
{
|
||||
before: () => {
|
||||
if (!this.configPython) {
|
||||
|
@ -128,7 +127,7 @@ PythonFinder.prototype = {
|
|||
]
|
||||
|
||||
if (this.win) {
|
||||
for (var i = 0; i < this.winDefaultLocations.length; ++i) {
|
||||
for (let i = 0; i < this.winDefaultLocations.length; ++i) {
|
||||
const location = this.winDefaultLocations[i]
|
||||
checks.push({
|
||||
before: () => {
|
||||
|
@ -181,9 +180,9 @@ PythonFinder.prototype = {
|
|||
// Will exit the Python finder on success.
|
||||
// If on Windows, run in a CMD shell to support BAT/CMD launchers.
|
||||
checkCommand: function checkCommand (command, errorCallback) {
|
||||
var exec = command
|
||||
var args = this.argsExecutable
|
||||
var shell = false
|
||||
let exec = command
|
||||
let args = this.argsExecutable
|
||||
let shell = false
|
||||
if (this.win) {
|
||||
// Arguments have to be manually quoted
|
||||
exec = `"${exec}"`
|
||||
|
@ -250,7 +249,7 @@ PythonFinder.prototype = {
|
|||
this.addLog(`- version is "${version}"`)
|
||||
|
||||
const range = new semver.Range(this.semverRange)
|
||||
var valid = false
|
||||
let valid = false
|
||||
try {
|
||||
valid = range.test(version)
|
||||
} catch (err) {
|
||||
|
@ -272,9 +271,9 @@ PythonFinder.prototype = {
|
|||
|
||||
// Run an executable or shell command, trimming the output.
|
||||
run: function run (exec, args, shell, callback) {
|
||||
var env = extend({}, this.env)
|
||||
const env = extend({}, this.env)
|
||||
env.TERM = 'dumb'
|
||||
const opts = { env: env, shell: shell }
|
||||
const opts = { env, shell }
|
||||
|
||||
this.log.silly('execFile: exec = %j', exec)
|
||||
this.log.silly('execFile: args = %j', args)
|
||||
|
@ -306,7 +305,8 @@ PythonFinder.prototype = {
|
|||
fail: function fail () {
|
||||
const errorLog = this.errorLog.join('\n')
|
||||
|
||||
const pathExample = this.win ? 'C:\\Path\\To\\python.exe'
|
||||
const pathExample = this.win
|
||||
? 'C:\\Path\\To\\python.exe'
|
||||
: '/path/to/pythonexecutable'
|
||||
// For Windows 80 col console, use up to the column before the one marked
|
||||
// with X (total 79 chars including logger prefix, 58 chars usable here):
|
||||
|
@ -333,12 +333,12 @@ PythonFinder.prototype = {
|
|||
}
|
||||
|
||||
function findPython (configPython, callback) {
|
||||
var finder = new PythonFinder(configPython, callback)
|
||||
const finder = new PythonFinder(configPython, callback)
|
||||
finder.findPython()
|
||||
}
|
||||
|
||||
module.exports = findPython
|
||||
module.exports.test = {
|
||||
PythonFinder: PythonFinder,
|
||||
findPython: findPython
|
||||
PythonFinder,
|
||||
findPython
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue