Skip to content

Commit 735c9d8

Browse files
committed
chore: fix unit tests
1 parent e4feeb2 commit 735c9d8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/plugins-service.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,26 @@ function createTestInjector() {
132132
generateHashes: async (files: string[]): Promise<IStringDictionary> => ({})
133133
});
134134
testInjector.register("pacoteService", {
135+
manifest: async (packageName: string) => {
136+
const projectData = testInjector.resolve("projectData");
137+
const fs = testInjector.resolve("fs");
138+
let result = {};
139+
let packageJsonPath = null;
140+
141+
const packageToInstall = packageName.split("@")[0];
142+
143+
if (fs.exists(packageToInstall)) {
144+
packageJsonPath = path.join(packageName, "package.json");
145+
} else {
146+
packageJsonPath = path.join(projectData.projectDir, "node_modules", packageToInstall, "package.json");
147+
}
148+
149+
if (fs.exists(packageJsonPath)) {
150+
result = fs.readJson(packageJsonPath);
151+
}
152+
153+
return result;
154+
},
135155
extractPackage: async (packageName: string, destinationDirectory: string, options?: IPacoteExtractOptions): Promise<void> => undefined
136156
});
137157
return testInjector;

0 commit comments

Comments
 (0)