Skip to content

Commit

Permalink
fix: hash plugin files after prepare (#5753)
Browse files Browse the repository at this point in the history
  • Loading branch information
mukaschultze authored Oct 6, 2023
1 parent c5f7b85 commit ecf1959
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
7 changes: 6 additions & 1 deletion lib/services/plugins-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,15 @@ export class PluginsService implements IPluginsService {
pluginData,
projectData
);

const updatedPluginNativeHashes = await this.getPluginNativeHashes(
pluginPlatformsFolderPath
);

this.setPluginNativeHashes({
pathToPluginsBuildFile,
pluginData,
currentPluginNativeHashes,
currentPluginNativeHashes: updatedPluginNativeHashes,
allPluginsNativeHashes,
});
}
Expand Down
30 changes: 26 additions & 4 deletions test/plugins-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ describe("Plugins service", () => {
newPluginHashes?: IStringDictionary;
buildDataFileExists?: boolean;
hasPluginPlatformsDir?: boolean;
pluginHashesAfterPrepare?: IStringDictionary;
}): any => {
const testData: any = {
pluginsService: null,
Expand Down Expand Up @@ -730,7 +731,10 @@ describe("Plugins service", () => {
currentPluginNativeHashes: IStringDictionary
) => !!opts.hasChangesInShasums,
generateHashes: async (files: string[]): Promise<IStringDictionary> =>
pluginHashes,
testData.isPreparePluginNativeCodeCalled &&
opts.pluginHashesAfterPrepare
? opts.pluginHashesAfterPrepare
: pluginHashes,
});

unitTestsInjector.register("fs", {
Expand Down Expand Up @@ -767,9 +771,8 @@ describe("Plugins service", () => {
unitTestsInjector.register("nodeModulesDependenciesBuilder", {});
unitTestsInjector.register("tempService", stubs.TempServiceStub);

const pluginsService: PluginsService = unitTestsInjector.resolve(
PluginsService
);
const pluginsService: PluginsService =
unitTestsInjector.resolve(PluginsService);
testData.pluginsService = pluginsService;
testData.pluginData = samplePluginData;
return testData;
Expand Down Expand Up @@ -805,6 +808,25 @@ describe("Plugins service", () => {
});
});

it("should hash the plugin files after prepare", async () => {
const newPluginHashes = { file: "hash" };
const pluginHashesAfterPrepare = { file: "hasedafterprepare" };
const testData = setupTest({
newPluginHashes,
hasPluginPlatformsDir: true,
pluginHashesAfterPrepare,
});
await testData.pluginsService.preparePluginNativeCode({
pluginData: testData.pluginData,
platform,
projectData,
});
assert.isTrue(testData.isPreparePluginNativeCodeCalled);
assert.deepStrictEqual(testData.dataPassedToWriteJson, {
[testData.pluginData.name]: pluginHashesAfterPrepare,
});
});

it("does not prepare the files when plugin has platforms dir and files have not changed since then", async () => {
const testData = setupTest({
hasChangesInShasums: false,
Expand Down

0 comments on commit ecf1959

Please sign in to comment.