1 | "use strict";
|
2 | const chalk = require('chalk');
|
3 | const child_process_1 = require('child_process');
|
4 | const config_1 = require('../models/config');
|
5 | const Promise = require('../ember-cli/lib/ext/promise');
|
6 | const execPromise = Promise.denodeify(child_process_1.exec);
|
7 | const packageManager = config_1.CliConfig.fromGlobal().get('packageManager');
|
8 | function 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 | }
|
28 | exports.checkYarnOrCNPM = checkYarnOrCNPM;
|
29 | function checkYarn() {
|
30 | return execPromise('yarn --version')
|
31 | .then(() => true, () => false);
|
32 | }
|
33 | function checkCNPM() {
|
34 | return execPromise('cnpm --version')
|
35 | .then(() => true, () => false);
|
36 | }
|
37 |
|
\ | No newline at end of file |