1 | "use strict";
|
2 |
|
3 |
|
4 | Object.defineProperty(exports, "__esModule", { value: true });
|
5 | const colors = require("colors");
|
6 | const path = require("path");
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | class RushCommandSelector {
|
15 | static failIfNotInvokedAsRush(version) {
|
16 | if (RushCommandSelector._getCommandName() === 'rushx') {
|
17 | RushCommandSelector._failWithError(`This repository is using Rush version ${version}`
|
18 | + ` which does not support the "rushx" command`);
|
19 | }
|
20 | }
|
21 |
|
22 | static execute(launcherVersion, selectedRushLib, options) {
|
23 | const Rush = selectedRushLib.Rush;
|
24 | if (!Rush) {
|
25 |
|
26 | RushCommandSelector._failWithError(`Unable to find the "Rush" entry point in @microsoft/rush-lib`);
|
27 | }
|
28 | if (RushCommandSelector._getCommandName() === 'rushx') {
|
29 | if (!Rush.launchRushX) {
|
30 | RushCommandSelector._failWithError(`This repository is using Rush version ${Rush.version}`
|
31 | + ` which does not support the "rushx" command`);
|
32 | }
|
33 | Rush.launchRushX(launcherVersion, {
|
34 | isManaged: options.isManaged,
|
35 | alreadyReportedNodeTooNewError: options.alreadyReportedNodeTooNewError
|
36 | });
|
37 | }
|
38 | else {
|
39 | Rush.launch(launcherVersion, {
|
40 | isManaged: options.isManaged,
|
41 | alreadyReportedNodeTooNewError: options.alreadyReportedNodeTooNewError
|
42 | });
|
43 | }
|
44 | }
|
45 | static _failWithError(message) {
|
46 | console.log(colors.red(message));
|
47 | return process.exit(1);
|
48 | }
|
49 | static _getCommandName() {
|
50 | if (process.argv.length >= 2) {
|
51 |
|
52 |
|
53 |
|
54 | const basename = path.basename(process.argv[1]).toUpperCase();
|
55 | if (basename === 'RUSHX') {
|
56 | return 'rushx';
|
57 | }
|
58 | if (basename === 'RUSH') {
|
59 | return 'rush';
|
60 | }
|
61 | }
|
62 | return undefined;
|
63 | }
|
64 | }
|
65 | exports.RushCommandSelector = RushCommandSelector;
|
66 |
|
\ | No newline at end of file |