Skip to content

Commit 2a7d405

Browse files
committed
fix: some yarn2 fixes
1 parent 5954ef6 commit 2a7d405

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/base-package-manager.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export abstract class BasePackageManager implements INodePackageManager {
130130
protected getFlagsString(config: any, asArray: boolean): any {
131131
const array: Array<string> = [];
132132
for (const flag in config) {
133-
if (flag === "global" && this.packageManager !== "yarn") {
133+
if (flag === "global" && this.packageManager !== "yarn" && this.packageManager !== "yarn2") {
134134
array.push(`--${flag}`);
135135
array.push(`${config[flag]}`);
136136
} else if (config[flag]) {
@@ -141,7 +141,12 @@ export abstract class BasePackageManager implements INodePackageManager {
141141
flag === "gradle" ||
142142
flag === "version_info"
143143
) {
144-
array.push(` ${flag}`);
144+
if (this.packageManager === "yarn2") {
145+
array.push(`--fields ${flag}`);
146+
} else {
147+
array.push(` ${flag}`);
148+
149+
}
145150
continue;
146151
}
147152
array.push(`--${flag}`);

lib/yarn2-package-manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,16 @@ export class Yarn2PackageManager extends BasePackageManager {
8989
let viewResult: any;
9090
try {
9191
viewResult = await this.$childProcess.exec(
92-
`yarn info ${packageName} ${flags}`
92+
`yarn npm info ${packageName} ${flags}`
9393
);
9494
} catch (e) {
9595
this.$errors.fail(e.message);
9696
}
9797

9898
try {
99-
const result = JSON.parse(viewResult);
100-
return result.data;
99+
return JSON.parse(viewResult);
101100
} catch (err) {
101+
this.$errors.fail(err.message);
102102
return null;
103103
}
104104
}

0 commit comments

Comments
 (0)