fix(core): properly throw error when failing to read workspace (#8835)
This commit is contained in:
parent
045c8dc9eb
commit
f069d8ec71
@ -15,26 +15,36 @@ import { parseRunOneOptions } from './parse-run-one-options';
|
|||||||
process.env.NX_CLI_SET = 'true';
|
process.env.NX_CLI_SET = 'true';
|
||||||
|
|
||||||
export function initLocal(workspace: Workspace) {
|
export function initLocal(workspace: Workspace) {
|
||||||
performance.mark('init-local');
|
try {
|
||||||
//nx-ignore-next-line
|
performance.mark('init-local');
|
||||||
require('@nrwl/workspace/src/utilities/perf-logging');
|
//nx-ignore-next-line
|
||||||
|
require('@nrwl/workspace/src/utilities/perf-logging');
|
||||||
|
|
||||||
const supportedNxCommands =
|
const supportedNxCommands =
|
||||||
//nx-ignore-next-line
|
//nx-ignore-next-line
|
||||||
require('@nrwl/workspace/src/command-line/supported-nx-commands').supportedNxCommands;
|
require('@nrwl/workspace/src/command-line/supported-nx-commands').supportedNxCommands;
|
||||||
|
|
||||||
|
if (supportedNxCommands.includes(process.argv[2])) {
|
||||||
|
// required to make sure nrwl/workspace import works
|
||||||
|
//nx-ignore-next-line
|
||||||
|
require('@nrwl/workspace/src/command-line/nx-commands').commandsObject
|
||||||
|
.argv;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (generating()) {
|
||||||
|
loadCli(workspace, '@nrwl/tao/index.js');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const runOpts = runOneOptions(workspace);
|
||||||
|
const running = runOpts !== false;
|
||||||
|
if (running) {
|
||||||
|
//nx-ignore-next-line
|
||||||
|
require('@nrwl/workspace/src/command-line/run-one').runOne(runOpts);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const runOpts = runOneOptions(workspace);
|
|
||||||
const running = runOpts !== false;
|
|
||||||
if (supportedNxCommands.includes(process.argv[2])) {
|
|
||||||
// required to make sure nrwl/workspace import works
|
|
||||||
//nx-ignore-next-line
|
|
||||||
require('@nrwl/workspace/src/command-line/nx-commands').commandsObject.argv;
|
|
||||||
} else if (running) {
|
|
||||||
//nx-ignore-next-line
|
|
||||||
require('@nrwl/workspace/src/command-line/run-one').runOne(runOpts);
|
|
||||||
} else if (generating()) {
|
|
||||||
loadCli(workspace, '@nrwl/tao/index.js');
|
|
||||||
} else {
|
|
||||||
if (workspace.type === 'nx') {
|
if (workspace.type === 'nx') {
|
||||||
loadCli(workspace, '@nrwl/tao/index.js');
|
loadCli(workspace, '@nrwl/tao/index.js');
|
||||||
} else {
|
} else {
|
||||||
@ -96,6 +106,9 @@ export function initLocal(workspace: Workspace) {
|
|||||||
loadCli(workspace, '@angular/cli/lib/init.js');
|
loadCli(workspace, '@angular/cli/lib/init.js');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e.message);
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,19 +125,15 @@ function loadCli(workspace: Workspace, cliPath: string) {
|
|||||||
function runOneOptions(
|
function runOneOptions(
|
||||||
workspace: Workspace
|
workspace: Workspace
|
||||||
): false | { project; target; configuration; parsedArgs } {
|
): false | { project; target; configuration; parsedArgs } {
|
||||||
try {
|
const workspaceConfig = new Workspaces(
|
||||||
const workspaceConfig = new Workspaces(
|
workspace.dir
|
||||||
workspace.dir
|
).readWorkspaceConfiguration();
|
||||||
).readWorkspaceConfiguration();
|
|
||||||
|
|
||||||
return parseRunOneOptions(
|
return parseRunOneOptions(
|
||||||
workspace.dir,
|
workspace.dir,
|
||||||
workspaceConfig,
|
workspaceConfig,
|
||||||
process.argv.slice(2)
|
process.argv.slice(2)
|
||||||
);
|
);
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function generating(): boolean {
|
function generating(): boolean {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user