Blame view

node_modules/bower/lib/commands/install.js 1.23 KB
2dda2e10   Administrator   generator ignore
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  var endpointParser = require('bower-endpoint-parser');
  var Project = require('../core/Project');
  var defaultConfig = require('../config');
  
  function install(logger, endpoints, options, config) {
      var project;
      var decEndpoints;
  
      options = options || {};
      config = defaultConfig(config);
      if (options.save === undefined) {
          options.save = config.defaultSave;
      }
      project = new Project(config, logger);
  
      // Convert endpoints to decomposed endpoints
      endpoints = endpoints || [];
      decEndpoints = endpoints.map(function (endpoint) {
          return endpointParser.decompose(endpoint);
      });
  
      return project.install(decEndpoints, options, config);
  }
  
  // -------------------
  
  install.readOptions = function (argv) {
      var cli = require('../util/cli');
  
      var options = cli.readOptions({
          'force-latest': { type: Boolean, shorthand: 'F'},
          'production': { type: Boolean, shorthand: 'p' },
          'save': { type: Boolean, shorthand: 'S' },
          'save-dev': { type: Boolean, shorthand: 'D' },
          'save-exact': { type: Boolean, shorthand: 'E' }
      }, argv);
  
      var packages = options.argv.remain.slice(1);
  
      delete options.argv;
  
      return [packages, options];
  };
  
  module.exports = install;