Skip to content

Commit 27f22e5

Browse files
committed
Refactoring the rush.json not found error throwing logic.
1 parent a091c79 commit 27f22e5

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

‎apps/rush-lib/src/api/RushConfiguration.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,12 @@ export class RushConfiguration {
208208

209209
public static loadFromDefaultLocation(): RushConfiguration {
210210
const rushJsonLocation: string | undefined = RushConfiguration.tryFindRushJsonLocation();
211-
return rushJsonLocation
212-
? RushConfiguration.loadFromConfigurationFile(rushJsonLocation)
213-
: Utilities.throwRushConfigNotFoundError();
211+
212+
if (rushJsonLocation) {
213+
return RushConfiguration.loadFromConfigurationFile(rushJsonLocation);
214+
} else {
215+
throw Utilities.getRushConfigNotFoundError();
216+
}
214217
}
215218

216219
/**

‎apps/rush-lib/src/cli/actions/BaseRushAction.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export abstract class BaseRushAction extends CommandLineAction {
6363
process.exitCode = 1;
6464

6565
if (!this.rushConfiguration) {
66-
Utilities.throwRushConfigNotFoundError();
66+
throw Utilities.getRushConfigNotFoundError();
6767
}
6868

6969
this._ensureEnvironment();

‎apps/rush-lib/src/utilities/Utilities.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import * as path from 'path';
1010
import * as wordwrap from 'wordwrap';
1111
import { JsonFile, IPackageJson } from '@microsoft/node-core-library';
1212

13-
import { RushConfiguration } from '../api/RushConfiguration';
14-
1513
export interface IEnvironment {
1614
// NOTE: the process.env doesn't actually support "undefined" as a value.
1715
// If you try to assign it, it will be converted to the text string "undefined".
@@ -515,8 +513,8 @@ export class Utilities {
515513
}
516514
}
517515

518-
public static throwRushConfigNotFoundError(): RushConfiguration {
519-
throw new Error('Unable to find rush.json configuration file');
516+
public static getRushConfigNotFoundError(): Error {
517+
return new Error('Unable to find rush.json configuration file');
520518
}
521519

522520
/**

0 commit comments

Comments
 (0)