"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/lib/rebuild.js" (11 Apr 2017, 3556 Bytes) of package /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 (function() {
    2   var Command, Install, Rebuild, _, config, path, yargs,
    3     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; },
    4     hasProp = {}.hasOwnProperty;
    5 
    6   path = require('path');
    7 
    8   _ = require('underscore-plus');
    9 
   10   yargs = require('yargs');
   11 
   12   config = require('./apm');
   13 
   14   Command = require('./command');
   15 
   16   Install = require('./install');
   17 
   18   module.exports = Rebuild = (function(superClass) {
   19     extend(Rebuild, superClass);
   20 
   21     Rebuild.commandNames = ['rebuild'];
   22 
   23     function Rebuild() {
   24       this.atomNodeDirectory = path.join(config.getAtomDirectory(), '.node-gyp');
   25       this.atomNpmPath = require.resolve('npm/bin/npm-cli');
   26     }
   27 
   28     Rebuild.prototype.parseOptions = function(argv) {
   29       var options;
   30       options = yargs(argv).wrap(100);
   31       options.usage("\nUsage: apm rebuild [<name> [<name> ...]]\n\nRebuild the given modules currently installed in the node_modules folder\nin the current working directory.\n\nAll the modules will be rebuilt if no module names are specified.");
   32       return options.alias('h', 'help').describe('help', 'Print this usage message');
   33     };
   34 
   35     Rebuild.prototype.installNode = function(callback) {
   36       return config.loadNpm(function(error, npm) {
   37         var install;
   38         install = new Install();
   39         install.npm = npm;
   40         return install.loadInstalledAtomMetadata(function() {
   41           return install.installNode(callback);
   42         });
   43       });
   44     };
   45 
   46     Rebuild.prototype.forkNpmRebuild = function(options, callback) {
   47       var env, rebuildArgs, vsArgs;
   48       process.stdout.write('Rebuilding modules ');
   49       rebuildArgs = ['--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), 'rebuild', '--runtime=electron', "--target=" + this.electronVersion, "--arch=" + (config.getElectronArch())];
   50       rebuildArgs = rebuildArgs.concat(options.argv._);
   51       if (vsArgs = this.getVisualStudioFlags()) {
   52         rebuildArgs.push(vsArgs);
   53       }
   54       env = _.extend({}, process.env, {
   55         HOME: this.atomNodeDirectory,
   56         RUSTUP_HOME: config.getRustupHomeDirPath()
   57       });
   58       if (config.isWin32()) {
   59         env.USERPROFILE = env.HOME;
   60       }
   61       this.addBuildEnvVars(env);
   62       return this.fork(this.atomNpmPath, rebuildArgs, {
   63         env: env
   64       }, callback);
   65     };
   66 
   67     Rebuild.prototype.run = function(options) {
   68       var callback;
   69       callback = options.callback;
   70       options = this.parseOptions(options.commandArgs);
   71       return config.loadNpm((function(_this) {
   72         return function(error, npm1) {
   73           _this.npm = npm1;
   74           return _this.loadInstalledAtomMetadata(function() {
   75             return _this.installNode(function(error) {
   76               if (error != null) {
   77                 return callback(error);
   78               }
   79               return _this.forkNpmRebuild(options, function(code, stderr) {
   80                 if (stderr == null) {
   81                   stderr = '';
   82                 }
   83                 if (code === 0) {
   84                   _this.logSuccess();
   85                   return callback();
   86                 } else {
   87                   _this.logFailure();
   88                   return callback(stderr);
   89                 }
   90               });
   91             });
   92           });
   93         };
   94       })(this));
   95     };
   96 
   97     return Rebuild;
   98 
   99   })(Command);
  100 
  101 }).call(this);