(function() {
  var CSON, Clean, Command, _, async, config, fs, path, yargs,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty,
    slice = [].slice;

  path = require('path');

  async = require('async');

  CSON = require('season');

  yargs = require('yargs');

  _ = require('underscore-plus');

  Command = require('./command');

  config = require('./apm');

  fs = require('./fs');

  module.exports = Clean = (function(superClass) {
    extend(Clean, superClass);

    Clean.commandNames = ['clean', 'prune'];

    function Clean() {
      Clean.__super__.constructor.call(this);
      this.atomNpmPath = require.resolve('npm/bin/npm-cli');
    }

    Clean.prototype.parseOptions = function(argv) {
      var options;
      options = yargs(argv).wrap(100);
      options.usage("Usage: apm clean\n\nDeletes all packages in the node_modules folder that are not referenced\nas a dependency in the package.json file.");
      return options.alias('h', 'help').describe('help', 'Print this usage message');
    };

    Clean.prototype.run = function(options) {
      process.stdout.write("Removing extraneous modules ");
      return this.fork(this.atomNpmPath, ['prune'], (function(_this) {
        return function() {
          var args;
          args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
          return _this.logCommandResults.apply(_this, [options.callback].concat(slice.call(args)));
        };
      })(this));
    };

    return Clean;

  })(Command);

}).call(this);
