mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 12:58:19 +02:00
Initial 'remove' command implementation.
This commit is contained in:
parent
a0d8740e55
commit
8a75de1cbb
1 changed files with 39 additions and 0 deletions
39
lib/remove.js
Normal file
39
lib/remove.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
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)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue