Skip to content

Commit 492bcd8

Browse files
committed
feat: cache commandLineParser in RushCommandLine api
1 parent d9f7817 commit 492bcd8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

libraries/rush-lib/src/api/RushCommandLine.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,15 @@ export interface ICommandLineSpec {
5656
* @beta
5757
*/
5858
export class RushCommandLine {
59+
private static _commandLineParser: RushCommandLineParser;
60+
5961
public static getSpec(workspaceFolder: string): ICommandLineSpec[] {
60-
const commandLineParser: RushCommandLineParser = new RushCommandLineParser({ cwd: workspaceFolder });
62+
if (!RushCommandLine._commandLineParser) {
63+
RushCommandLine._commandLineParser = new RushCommandLineParser({ cwd: workspaceFolder });
64+
}
6165

6266
// Copy the actions
63-
const commandLineActions: CommandLineAction[] = commandLineParser.actions.slice();
67+
const commandLineActions: readonly CommandLineAction[] = RushCommandLine._commandLineParser.actions;
6468

6569
// extract the set of command line elements from the command line parser
6670
const filledCommandLineActions: ICommandLineSpec[] = [];

0 commit comments

Comments
 (0)