"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/node-gyp/lib/remove.js" (8 Mar 2017, 1319 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

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