Skip to content

Commit 250dce9

Browse files
clydinhansl
authored andcommitted
fix(@angular/cli): correct package manager option logic
1 parent 3c0a546 commit 250dce9

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

packages/@angular/cli/commands/config.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,15 @@ export default class ConfigCommand extends Command {
164164

165165
public run(options: ConfigOptions) {
166166
const level = options.global ? 'global' : 'local';
167-
const config =
167+
168+
if (options.value == undefined) {
169+
const config =
168170
(getWorkspace(level) as {} as { _workspace: experimental.workspace.WorkspaceSchema });
169171

170-
if (!config) {
171-
throw new SilentError('No config found.');
172-
}
172+
if (!config) {
173+
throw new SilentError('No config found.');
174+
}
173175

174-
if (options.value == undefined) {
175176
this.get(config._workspace, options);
176177
} else {
177178
this.set(options);

packages/@angular/cli/utilities/config.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import { NodeJsSyncHost } from '@angular-devkit/core/node';
1414
import { findUp } from './find-up';
1515

1616
function getSchemaLocation(): string {
17-
const packagePath = require.resolve('@angular-devkit/core/package.json');
18-
19-
return path.join(path.dirname(packagePath), 'src/workspace/workspace-schema.json');
17+
return path.join(__dirname, '../lib/config/schema.json');
2018
}
2119

2220
export const workspaceSchemaPath = getSchemaLocation();
@@ -59,12 +57,8 @@ export function getWorkspace(
5957
let configPath = level === 'local' ? projectFilePath() : globalFilePath();
6058

6159
if (!configPath) {
62-
if (level === 'global') {
63-
configPath = createGlobalSettings();
64-
} else {
65-
cachedWorkspaces.set(level, null);
66-
return null;
67-
}
60+
cachedWorkspaces.set(level, null);
61+
return null;
6862
}
6963

7064
const root = normalize(path.dirname(configPath));
@@ -79,7 +73,7 @@ export function getWorkspace(
7973
return workspace;
8074
}
8175

82-
function createGlobalSettings(): string {
76+
export function createGlobalSettings(): string {
8377
const home = os.homedir();
8478
if (!home) {
8579
throw new Error('No home directory found.');
@@ -135,7 +129,7 @@ export function validateWorkspace(json: JsonValue) {
135129
}
136130

137131
export function getPackageManager(): string {
138-
let workspace = getWorkspace();
132+
let workspace = getWorkspace('local');
139133

140134
if (workspace) {
141135
const project = workspace.getProjectByPath(normalize(process.cwd()));
@@ -144,7 +138,8 @@ export function getPackageManager(): string {
144138
if (typeof value == 'string') {
145139
return value;
146140
}
147-
} else if (workspace.getCli()) {
141+
}
142+
if (workspace.getCli()) {
148143
const value = workspace.getCli()['packageManager'];
149144
if (typeof value == 'string') {
150145
return value;
@@ -253,7 +248,8 @@ export function isWarningEnabled(warning: string): boolean {
253248
return value;
254249
}
255250
}
256-
} else if (workspace.getCli()) {
251+
}
252+
if (workspace.getCli()) {
257253
const warnings = workspace.getCli()['warnings'];
258254
if (typeof warnings == 'object' && !Array.isArray(warnings)) {
259255
const value = warnings[warning];

0 commit comments

Comments
 (0)