list.js 718 B

123456789101112131415161718192021222324252627282930313233
  1. module.exports = exports = list
  2. exports.usage = 'Prints a listing of the currently installed node development files'
  3. /**
  4. * Module dependencies.
  5. */
  6. var fs = require('graceful-fs')
  7. , path = require('path')
  8. , log = require('npmlog')
  9. function list (gyp, args, callback) {
  10. var devDir = gyp.devDir
  11. log.verbose('list', 'using node-gyp dir:', devDir)
  12. // readdir() the node-gyp dir
  13. fs.readdir(devDir, onreaddir)
  14. function onreaddir (err, versions) {
  15. if (err && err.code != 'ENOENT') {
  16. return callback(err)
  17. }
  18. if (Array.isArray(versions)) {
  19. versions = versions.filter(function (v) { return v != 'current' })
  20. } else {
  21. versions = []
  22. }
  23. callback(null, versions)
  24. }
  25. }