1 | var endpointParser = require('bower-endpoint-parser');
|
2 | var Project = require('../core/Project');
|
3 | var defaultConfig = require('../config');
|
4 |
|
5 | function install(logger, endpoints, options, config) {
|
6 | var project;
|
7 | var decEndpoints;
|
8 |
|
9 | options = options || {};
|
10 | config = defaultConfig(config);
|
11 | if (options.save === undefined) {
|
12 | options.save = config.defaultSave;
|
13 | }
|
14 | project = new Project(config, logger);
|
15 |
|
16 |
|
17 | endpoints = endpoints || [];
|
18 | decEndpoints = endpoints.map(function(endpoint) {
|
19 |
|
20 | var splitParts = endpoint.split('/');
|
21 | splitParts[splitParts.length - 1] = splitParts[
|
22 | splitParts.length - 1
|
23 | ].replace('@', '#');
|
24 | endpoint = splitParts.join('/');
|
25 |
|
26 | return endpointParser.decompose(endpoint);
|
27 | });
|
28 |
|
29 | return project.install(decEndpoints, options, config);
|
30 | }
|
31 |
|
32 |
|
33 |
|
34 | install.readOptions = function(argv) {
|
35 | var cli = require('../util/cli');
|
36 |
|
37 | var options = cli.readOptions(
|
38 | {
|
39 | 'force-latest': { type: Boolean, shorthand: 'F' },
|
40 | production: { type: Boolean, shorthand: 'p' },
|
41 | save: { type: Boolean, shorthand: 'S' },
|
42 | 'save-dev': { type: Boolean, shorthand: 'D' },
|
43 | 'save-exact': { type: Boolean, shorthand: 'E' }
|
44 | },
|
45 | argv
|
46 | );
|
47 |
|
48 | var packages = options.argv.remain.slice(1);
|
49 |
|
50 | delete options.argv;
|
51 |
|
52 | return [packages, options];
|
53 | };
|
54 |
|
55 | module.exports = install;
|