Skip to content

Commit 2197d0e

Browse files
committed
install-run-rushx.ts should just be an alias
1 parent ed81833 commit 2197d0e

File tree

2 files changed

+5
-74
lines changed

2 files changed

+5
-74
lines changed

apps/rush-lib/src/scripts/install-run-rush.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ function run(): void {
4949
...packageBinArgs /* [build, --to, myproject] */
5050
]: string[] = process.argv;
5151

52+
const scriptName = path.basename(scriptPath);
53+
const bin = scriptName.toLowerCase() === 'install-run-rushx.js' ? 'rushx' : 'rush';
5254
if (!nodePath || !scriptPath) {
5355
throw new Error('Unexpected exception: could not detect node path or script path');
5456
}
5557

5658
if (process.argv.length < 3) {
57-
console.log('Usage: install-run-rush.js <command> [args...]');
58-
console.log('Example: install-run-rush.js build --to myproject');
59+
console.log('Usage: ${scriptName} <command> [args...]');
60+
console.log('Example: ${scriptName} build --to myproject');
5961
process.exit(1);
6062
}
6163

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2-
// See the @microsoft/rush package's LICENSE file for license information.
3-
4-
// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED.
5-
//
6-
// This script is intended for usage in an automated build environment where the Rush command may not have
7-
// been preinstalled, or may have an unpredictable version. This script will automatically install the version of Rush
8-
// specified in the rush.json configuration file (if not already installed), and then pass a command-line to it.
9-
// An example usage would be:
10-
//
11-
// node common/scripts/install-run-rushx.js install
12-
//
13-
// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/
14-
15-
import * as path from 'path';
16-
import * as fs from 'fs';
17-
18-
import {
19-
installAndRun,
20-
findRushJsonFolder,
21-
RUSH_JSON_FILENAME,
22-
runWithErrorAndStatusCode
23-
} from './install-run';
24-
25-
const PACKAGE_NAME: string = '@microsoft/rush';
26-
27-
function getRushVersion(): string {
28-
const rushJsonFolder: string = findRushJsonFolder();
29-
const rushJsonPath: string = path.join(rushJsonFolder, RUSH_JSON_FILENAME);
30-
try {
31-
const rushJsonContents: string = fs.readFileSync(rushJsonPath, 'utf-8');
32-
// Use a regular expression to parse out the rushVersion value because rush.json supports comments,
33-
// but JSON.parse does not and we don't want to pull in more dependencies than we need to in this script.
34-
const rushJsonMatches: string[] = rushJsonContents.match(/\"rushVersion\"\s*\:\s*\"([0-9a-zA-Z.+\-]+)\"/)!;
35-
return rushJsonMatches[1];
36-
} catch (e) {
37-
throw new Error(
38-
`Unable to determine the required version of Rush from rush.json (${rushJsonFolder}). ` +
39-
'The \'rushVersion\' field is either not assigned in rush.json or was specified ' +
40-
'using an unexpected syntax.'
41-
);
42-
}
43-
}
44-
45-
function run(): void {
46-
const [
47-
nodePath, /* Ex: /bin/node */
48-
scriptPath, /* /repo/common/scripts/install-run-rushx.js */
49-
...packageBinArgs /* [build, --verbose] */
50-
]: string[] = process.argv;
51-
52-
const scriptName = path.basename(scriptPath);
53-
const bin = scriptName.toLowerCase() === 'install-run-rushx.js' ? 'rushx' : 'rush';
54-
if (!nodePath || !scriptPath) {
55-
throw new Error('Unexpected exception: could not detect node path or script path');
56-
}
57-
58-
if (process.argv.length < 3) {
59-
console.log(`Usage: ${scriptName} <command> [args...]`);
60-
console.log(`Example: ${scriptName} build`);
61-
process.exit(1);
62-
}
63-
64-
runWithErrorAndStatusCode(() => {
65-
const version: string = getRushVersion();
66-
console.log(`The rush.json configuration requests Rush version ${version}`);
67-
68-
return installAndRun(PACKAGE_NAME, version, bin, packageBinArgs);
69-
});
70-
}
71-
72-
run();
1+
require("./install-run-rush");

0 commit comments

Comments
 (0)