Skip to content

Commit

Permalink
fix spawn EINVAL error
Browse files Browse the repository at this point in the history
  • Loading branch information
derevnjuk committed Apr 15, 2024
1 parent 5b2c606 commit 816f06b
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var proc = require('child_process')
var execspawn = require('execspawn')
var childProcess = require('child_process')
var os = require('os')
var path = require('path')
var fs = require('fs')
Expand All @@ -19,7 +18,7 @@ function prebuildify (opts, cb) {
strip: process.env.PREBUILD_STRIP === '1',
stripBin: process.env.PREBUILD_STRIP_BIN || 'strip',
nodeGyp: process.env.PREBUILD_NODE_GYP || npmbin('node-gyp'),
shell: process.env.PREBUILD_SHELL || shell(),
shell: process.env.PREBUILD_SHELL || true,
cwd: '.',
targets: []
}, opts)
Expand Down Expand Up @@ -179,11 +178,12 @@ function copySharedLibs (builds, folder, opts, cb) {
function run (cmd, opts, cb) {
if (!cmd) return cb()

var child = execspawn(cmd, {
var child = childProcess.spawn(cmd, [], {
cwd: opts.cwd,
env: opts.env,
stdio: 'inherit',
shell: opts.shell
stdio: opts.quiet ? 'ignore' : 'inherit',
shell: opts.shell,
windowsHide: true
})

child.on('exit', function (code) {
Expand Down Expand Up @@ -227,9 +227,11 @@ function build (target, runtime, opts, cb) {
}

mkdirp(cache, function () {
var child = proc.spawn(opts.nodeGyp, args, {
var child = childProcess.spawn(opts.nodeGyp, args, {
cwd: opts.cwd,
env: opts.env,
shell: opts.shell,
windowsHide: true,
stdio: opts.quiet ? 'ignore' : 'inherit'
})

Expand Down Expand Up @@ -266,7 +268,13 @@ function strip (file, opts, cb) {
if (!opts.strip || (platform !== 'darwin' && platform !== 'linux')) return cb()

var args = platform === 'darwin' ? [file, '-Sx'] : [file, '--strip-all']
var child = proc.spawn(opts.stripBin, args, { stdio: 'ignore' })
var child = childProcess.spawn(opts.stripBin, args, {
stdio: 'ignore',
cwd: opts.cwd,
env: opts.env,
shell: opts.shell,
windowsHide: true
})

child.on('exit', function (code) {
if (code) return cb(spawnError(opts.stripBin, code))
Expand Down Expand Up @@ -299,10 +307,6 @@ function npmbin (name) {
return os.platform() === 'win32' ? name + '.cmd' : name
}

function shell () {
return os.platform() === 'android' ? 'sh' : undefined
}

function resolveTargets (targets, all, napi, electronCompat) {
targets = targets.map(function (v) {
if (typeof v === 'object' && v !== null) return v
Expand Down

0 comments on commit 816f06b

Please sign in to comment.