Skip to content

Commit c9d9203

Browse files
committed
fix: more pnpm fixes
1 parent 2632da1 commit c9d9203

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/pnpm-package-manager.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as path from "path";
22
import { BasePackageManager } from "./base-package-manager";
33
import { exported } from './common/decorators';
4+
import { CACACHE_DIRECTORY_NAME } from "./constants";
45

56
export class PnpmPackageManager extends BasePackageManager {
67

@@ -29,10 +30,11 @@ export class PnpmPackageManager extends BasePackageManager {
2930
const jsonContentBefore = this.$fs.readJson(packageJsonPath);
3031

3132
const flags = this.getFlagsString(config, true);
32-
let params = [];
33+
// With pnpm we need to install as "flat" or some imports wont be found
34+
let params = ['i', '--shamefully-hoist'];
3335
const isInstallingAllDependencies = packageName === pathToSave;
3436
if (!isInstallingAllDependencies) {
35-
params.push('i', packageName);
37+
params.push(packageName);
3638
}
3739

3840
params = params.concat(flags);
@@ -64,15 +66,14 @@ export class PnpmPackageManager extends BasePackageManager {
6466
} catch (e) {
6567
this.$errors.fail(e.message);
6668
}
67-
6869
const result = JSON.parse(viewResult);
69-
return result.data;
70+
return result;
7071
}
7172

7273
@exported("pnpm")
7374
public search(filter: string[], config: IDictionary<string | boolean>): Promise<string> {
74-
this.$errors.fail("Method not implemented. pnpm does not support searching for packages in the registry.");
75-
return null;
75+
const flags = this.getFlagsString(config, false);
76+
return this.$childProcess.exec(`pnpm search ${filter.join(" ")} ${flags}`);
7677
}
7778

7879
public async searchNpms(keyword: string): Promise<INpmsResult> {
@@ -95,8 +96,8 @@ export class PnpmPackageManager extends BasePackageManager {
9596

9697
@exported("pnpm")
9798
public async getCachePath(): Promise<string> {
98-
const result = await this.$childProcess.exec(`pnpm cache dir`);
99-
return result.toString().trim();
99+
const cachePath = await this.$childProcess.exec(`pnpm config get cache`);
100+
return path.join(cachePath.trim(), CACACHE_DIRECTORY_NAME);
100101
}
101102
}
102103

0 commit comments

Comments
 (0)