source: trip-planner-front/node_modules/node-gyp/lib/remove.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[6a3a178]1'use strict'
2
3const fs = require('fs')
4const rm = require('rimraf')
5const path = require('path')
6const log = require('npmlog')
7const semver = require('semver')
8
9function remove (gyp, argv, callback) {
10 var devDir = gyp.devDir
11 log.verbose('remove', 'using node-gyp dir:', devDir)
12
13 // get the user-specified version to remove
14 var version = argv[0] || gyp.opts.target
15 log.verbose('remove', 'removing target version:', version)
16
17 if (!version) {
18 return callback(new Error('You must specify a version number to remove. Ex: "' + process.version + '"'))
19 }
20
21 var versionSemver = semver.parse(version)
22 if (versionSemver) {
23 // flatten the version Array into a String
24 version = versionSemver.version
25 }
26
27 var versionPath = path.resolve(gyp.devDir, version)
28 log.verbose('remove', 'removing development files for version:', version)
29
30 // first check if its even installed
31 fs.stat(versionPath, function (err) {
32 if (err) {
33 if (err.code === 'ENOENT') {
34 callback(null, 'version was already uninstalled: ' + version)
35 } else {
36 callback(err)
37 }
38 return
39 }
40 // Go ahead and delete the dir
41 rm(versionPath, callback)
42 })
43}
44
45module.exports = exports = remove
46module.exports.usage = 'Removes the node development files for the specified version'
Note: See TracBrowser for help on using the repository browser.