"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/lib/config.js" (8 Mar 2017, 2417 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 (function() {
    2   var Command, Config, _, apm, 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   apm = require('./apm');
   13 
   14   Command = require('./command');
   15 
   16   module.exports = Config = (function(superClass) {
   17     extend(Config, superClass);
   18 
   19     Config.commandNames = ['config'];
   20 
   21     function Config() {
   22       var atomDirectory;
   23       atomDirectory = apm.getAtomDirectory();
   24       this.atomNodeDirectory = path.join(atomDirectory, '.node-gyp');
   25       this.atomNpmPath = require.resolve('npm/bin/npm-cli');
   26     }
   27 
   28     Config.prototype.parseOptions = function(argv) {
   29       var options;
   30       options = yargs(argv).wrap(100);
   31       options.usage("\nUsage: apm config set <key> <value>\n       apm config get <key>\n       apm config delete <key>\n       apm config list\n       apm config edit\n");
   32       return options.alias('h', 'help').describe('help', 'Print this usage message');
   33     };
   34 
   35     Config.prototype.run = function(options) {
   36       var callback, configArgs, configOptions, env;
   37       callback = options.callback;
   38       options = this.parseOptions(options.commandArgs);
   39       configArgs = ['--globalconfig', apm.getGlobalConfigPath(), '--userconfig', apm.getUserConfigPath(), 'config'];
   40       configArgs = configArgs.concat(options.argv._);
   41       env = _.extend({}, process.env, {
   42         HOME: this.atomNodeDirectory,
   43         RUSTUP_HOME: apm.getRustupHomeDirPath()
   44       });
   45       configOptions = {
   46         env: env
   47       };
   48       return this.fork(this.atomNpmPath, configArgs, configOptions, function(code, stderr, stdout) {
   49         if (stderr == null) {
   50           stderr = '';
   51         }
   52         if (stdout == null) {
   53           stdout = '';
   54         }
   55         if (code === 0) {
   56           if (stdout) {
   57             process.stdout.write(stdout);
   58           }
   59           return callback();
   60         } else {
   61           if (stderr) {
   62             process.stdout.write(stderr);
   63           }
   64           return callback(new Error("npm config failed: " + code));
   65         }
   66       });
   67     };
   68 
   69     return Config;
   70 
   71   })(Command);
   72 
   73 }).call(this);