-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install-packages-globally.js
24 lines (21 loc) · 1022 Bytes
/
install-packages-globally.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"use strict";
const toPlainObject = require("es5-ext/object/normalize-options")
, ensureConfiguration = require("./lib/ensure-user-configuration")
, createProgressData = require("./lib/create-progress-data")
, installPackageGlobally = require("./lib/install-package-globally")
, tokenizePackageSpecs = require("./lib/utils/tokenize-package-specs");
module.exports = (packageNames, userConfiguration, inputOptions = {}) => {
const packageSpecsData = tokenizePackageSpecs(packageNames);
userConfiguration = ensureConfiguration(userConfiguration);
inputOptions = toPlainObject(inputOptions);
const progressData = createProgressData();
const promise = packageSpecsData.reduce(async (previousPromise, packageContext) => {
await previousPromise;
progressData.topPackageName = packageContext.name;
return installPackageGlobally(
packageContext, userConfiguration, inputOptions, progressData
);
}, Promise.resolve());
promise.progressData = progressData;
return promise;
};