Front end of the Slack clone application.

remove.js 1.3KB

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