@@ -9,48 +9,12 @@ import * as path from 'path';
99import {
1010 PackageJsonLookup ,
1111 IPackageJson ,
12- Text ,
13- IPackageJsonScriptTable
12+ Text
1413 } from '@microsoft/node-core-library' ;
1514import { Utilities } from '../utilities/Utilities' ;
15+ import { ProjectCommandSet } from '../logic/ProjectCommandSet' ;
1616
17- /**
18- * Parses the "scripts" section from package.json
19- */
20- class ProjectCommandSet {
21- public readonly malformedScriptNames : string [ ] = [ ] ;
22- public readonly commandNames : string [ ] = [ ] ;
23- private readonly _scriptsByName : Map < string , string > = new Map < string , string > ( ) ;
24-
25- public constructor ( packageJson : IPackageJson ) {
26- const scripts : IPackageJsonScriptTable = packageJson . scripts || { } ;
27-
28- for ( const scriptName of Object . keys ( scripts ) ) {
29- if ( scriptName [ 0 ] === '-' || scriptName . length === 0 ) {
30- this . malformedScriptNames . push ( scriptName ) ;
31- } else {
32- this . commandNames . push ( scriptName ) ;
33- this . _scriptsByName . set ( scriptName , scripts [ scriptName ] ) ;
34- }
35- }
36-
37- this . commandNames . sort ( ) ;
38- }
39-
40- public tryGetScriptBody ( commandName : string ) : string | undefined {
41- return this . _scriptsByName . get ( commandName ) ;
42- }
43-
44- public getScriptBody ( commandName : string ) : string {
45- const result : string | undefined = this . tryGetScriptBody ( commandName ) ;
46- if ( result === undefined ) {
47- throw new Error ( `The command "${ commandName } " was not found` ) ;
48- }
49- return result ;
50- }
51- }
52-
53- export class RushX {
17+ export class RushXCommandLine {
5418 public static launchRushX ( launcherVersion : string , isManaged : boolean ) : void {
5519 // NodeJS can sometimes accidentally terminate with a zero exit code (e.g. for an uncaught
5620 // promise exception), so we start with the assumption that the exit code is 1
@@ -82,7 +46,7 @@ export class RushX {
8246 // rush -h
8347 // rush --unrecognized-option
8448 if ( args . length === 0 || args [ 0 ] [ 0 ] === '-' ) {
85- RushX . _showUsage ( packageJson , projectCommandSet ) ;
49+ RushXCommandLine . _showUsage ( packageJson , projectCommandSet ) ;
8650 return ;
8751 }
8852
0 commit comments