mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 12:58:19 +02:00
39 lines
916 B
JavaScript
39 lines
916 B
JavaScript
|
|
module.exports = exports = remove
|
|
|
|
exports.usage = 'Removes the node development files for the specified version'
|
|
|
|
/**
|
|
* Module dependencies.
|
|
*/
|
|
|
|
var fs = require('fs')
|
|
, rm = require('rimraf')
|
|
, path = require('path')
|
|
|
|
function remove (gyp, argv, callback) {
|
|
|
|
// TODO: Make ~/.node-gyp configurable
|
|
var nodeGypDir = path.join(process.env.HOME, '.node-gyp')
|
|
|
|
gyp.verbose('using node-gyp dir', nodeGypDir)
|
|
|
|
var version = parseFloat(argv[0] || gyp.opts.target)
|
|
, versionPath = path.join(nodeGypDir, version.toString())
|
|
|
|
gyp.verbose('removing development files for version', version)
|
|
|
|
fs.stat(versionPath, function (err, stat) {
|
|
if (err) {
|
|
if (err.code == 'ENOENT') {
|
|
gyp.info('version was already not installed', version)
|
|
callback()
|
|
} else {
|
|
callback(err)
|
|
}
|
|
return
|
|
}
|
|
// Go ahead and delete the dir
|
|
rm(versionPath, callback)
|
|
})
|
|
}
|