UNPKG

1.45 kBJavaScriptView Raw
1"use strict";
2const chalk = require('chalk');
3const child_process_1 = require('child_process');
4const config_1 = require('../models/config');
5const Promise = require('../ember-cli/lib/ext/promise');
6const execPromise = Promise.denodeify(child_process_1.exec);
7const packageManager = config_1.CliConfig.fromGlobal().get('packageManager');
8function checkYarnOrCNPM() {
9 if (packageManager !== 'default') {
10 return Promise.resolve();
11 }
12 return Promise
13 .all([checkYarn(), checkCNPM()])
14 .then((data) => {
15 const [isYarnInstalled, isCNPMInstalled] = data;
16 if (isYarnInstalled && isCNPMInstalled) {
17 console.log(chalk.yellow('You can `ng set --global packageManager=yarn` '
18 + 'or `ng set --global packageManager=cnpm`.'));
19 }
20 else if (isYarnInstalled) {
21 console.log(chalk.yellow('You can `ng set --global packageManager=yarn`.'));
22 }
23 else if (isCNPMInstalled) {
24 console.log(chalk.yellow('You can `ng set --global packageManager=cnpm`.'));
25 }
26 });
27}
28exports.checkYarnOrCNPM = checkYarnOrCNPM;
29function checkYarn() {
30 return execPromise('yarn --version')
31 .then(() => true, () => false);
32}
33function checkCNPM() {
34 return execPromise('cnpm --version')
35 .then(() => true, () => false);
36}
37//# sourceMappingURL=/Users/hansl/Sources/angular-cli/packages/@angular/cli/utilities/check-package-manager.js.map
\No newline at end of file