Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions bin/node-gyp.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ if (dir) {
}
}

function run () {
async function run () {
const command = prog.todo.shift()
if (!command) {
// done!
Expand All @@ -77,30 +77,28 @@ function run () {
return
}

prog.commands[command.name](command.args, function (err) {
if (err) {
log.error(command.name + ' error')
log.error('stack', err.stack)
errorMessage()
log.error('not ok')
return process.exit(1)
}
try {
const args = await prog.commands[command.name](command.args) ?? []

if (command.name === 'list') {
const versions = arguments[1]
if (versions.length > 0) {
versions.forEach(function (version) {
console.log(version)
})
if (args.length) {
args.forEach((version) => console.log(version))
} else {
console.log('No node development files installed. Use `node-gyp install` to install a version.')
}
} else if (arguments.length >= 2) {
console.log.apply(console, [].slice.call(arguments, 1))
} else if (args.length >= 1) {
console.log(...args.slice(1))
}

// now run the next command in the queue
process.nextTick(run)
})
return run()
} catch (err) {
log.error(command.name + ' error')
log.error('stack', err.stack)
errorMessage()
log.error('not ok')
return process.exit(1)
}
}

process.on('exit', function (code) {
Expand Down
12 changes: 2 additions & 10 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,7 @@ async function build (gyp, argv) {
await new Promise((resolve, reject) => proc.on('exit', async (code, signal) => {
if (buildBinsDir) {
// Clean up the build-time dependency symlinks:
if (fs.rm) {
// fs.rm is only available in Node 14+
await fs.rm(buildBinsDir, { recursive: true })
} else {
// Only used for old node, as recursive rmdir is deprecated in Node 14+
await fs.rmdir(buildBinsDir, { recursive: true })
}
await fs.rm(buildBinsDir, { recursive: true })
}

if (code !== 0) {
Expand All @@ -222,7 +216,5 @@ async function build (gyp, argv) {
}
}

module.exports = function (gyp, argv, callback) {
build(gyp, argv).then(callback.bind(undefined, null), callback)
}
module.exports = build
module.exports.usage = 'Invokes `' + (win ? 'msbuild' : 'make') + '` and builds the module'
6 changes: 2 additions & 4 deletions lib/clean.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const fs = require('fs/promises')
const fs = require('graceful-fs').promises
const log = require('./log')

async function clean (gyp, argv) {
Expand All @@ -11,7 +11,5 @@ async function clean (gyp, argv) {
await fs.rm(buildDir, { recursive: true, force: true })
}

module.exports = function (gyp, argv, callback) {
clean(gyp, argv).then(callback.bind(undefined, null), callback)
}
module.exports = clean
module.exports.usage = 'Removes any generated build files and the "out" dir'
Loading