UNPKG

prebuild

Version:

A command line tool for easily making prebuilt binaries for multiple versions of node, electron or node-webkit on a specific platform

40 lines (33 loc) 1.12 kB
var spawn = require('child_process').spawn var which = require('npm-which')(process.cwd()) function runCmake (opts, target, cb) { which('cmake-js', function (err, cmakeJsPath) { if (err) return cb(err) var args = ['rebuild'] if (opts.runtime !== 'napi') args.push('--runtime-version=' + target) args.push('--arch=' + opts.arch) if (opts.runtime !== 'napi') args.push('--runtime=' + opts.runtime) if (opts.runtime === 'napi' && target) { args.push('--CDnapi_build_version=' + target) } if (opts.debug) args.push('--debug') var foundRest = false for (var arg of opts.argv) { if (arg === '--') { foundRest = true } else if (foundRest) { args.push(arg) } } var proc = spawn(cmakeJsPath, args, process.platform === 'win32' ? { shell: true } : undefined) proc.stdout.pipe(process.stdout) proc.stderr.pipe(process.stderr) proc.on('exit', function (code) { if (code !== 0) { return cb(new Error('Failed to build cmake with exit code ' + code)) } cb() }) }) } module.exports = runCmake