node-gyp/lib/list.js
Luke Karrys 355622f4aa feat: convert all internal functions to async/await
BREAKING CHANGE: All internal functions have been coverted to return
promises and no longer accept callbacks. This is not a breaking change
for users but may be breaking to consumers of `node-gyp` if you are
requiring internal functions directly.
2023-10-28 08:59:57 -07:00

26 lines
580 B
JavaScript

'use strict'
const fs = require('graceful-fs').promises
const log = require('./log')
async function list (gyp, args) {
const devDir = gyp.devDir
log.verbose('list', 'using node-gyp dir:', devDir)
let versions = []
try {
const dir = await fs.readdir(devDir)
if (Array.isArray(dir)) {
versions = dir.filter((v) => v !== 'current')
}
} catch (err) {
if (err && err.code !== 'ENOENT') {
throw err
}
}
return versions
}
module.exports = list
module.exports.usage = 'Prints a listing of the currently installed node development files'