1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

feat: Make pushing linkables happen automatically when using re-usable build script

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2023-04-28 10:57:56 +03:00 committed by Iku-turso
parent 355ff3296a
commit 7e66181be5
3 changed files with 70 additions and 5 deletions

View File

@ -36,7 +36,8 @@
"tailwindcss": "^3.3.2",
"ts-loader": "^9.4.1",
"webpack": "^5.81.0",
"webpack-cli": "^4.10.0"
"webpack-cli": "^4.10.0",
"@ogre-tools/linkable": "^15.8.0"
},
"peerDependencies": {
"@ogre-tools/fp": "^15.8.0",

View File

@ -47,6 +47,27 @@ describe("do-webpack-build", () => {
expect(logSuccessMock).toHaveBeenCalledWith("some-stdout");
});
it("makes the built package available for local packages in development that link to it", () => {
expect(execMock).toHaveBeenCalledWith("linkable-push");
});
it("does not finish script yet", async () => {
const promiseStatus = await getPromiseStatus(actualPromise);
expect(promiseStatus.fulfilled).toBe(false);
});
describe("when linking resolves with stdout", () => {
beforeEach(async () => {
logSuccessMock.mockClear();
await execMock.resolve({ stdout: "some-other-stdout", stderr: "" });
});
it("logs the stdout", () => {
expect(logSuccessMock).toHaveBeenCalledWith("some-other-stdout");
});
it("script finishes", async () => {
const promiseStatus = await getPromiseStatus(actualPromise);
@ -54,6 +75,43 @@ describe("do-webpack-build", () => {
});
});
describe("when linking resolves with stderr", () => {
beforeEach(() => {
logSuccessMock.mockClear();
execMock.resolve({ stdout: "", stderr: "some-other-stderr" });
});
it("does not log success", () => {
actualPromise.catch(() => {});
expect(logSuccessMock).not.toHaveBeenCalled();
});
it("throws", () => {
return expect(actualPromise).rejects.toThrow("some-other-stderr");
});
});
describe("when linking rejects", () => {
beforeEach(() => {
logSuccessMock.mockClear();
execMock.reject(new Error("some-other-error"));
});
it("does not log success", () => {
actualPromise.catch(() => {});
expect(logSuccessMock).not.toHaveBeenCalled();
});
it("throws", () => {
return expect(actualPromise).rejects.toThrow("some-other-error");
});
});
});
describe("when webpack resolves with stderr", () => {
beforeEach(() => {
execMock.resolve({ stdout: "", stderr: "some-stderr" });

View File

@ -11,8 +11,8 @@ export const doWebpackBuildInjectable = getInjectable({
const exec = di.inject(execInjectable);
const logSuccess = di.inject(logSuccessInjectable);
return async () => {
const { stdout, stderr } = await exec("webpack");
const execWithResultHandling = async (command: string) => {
const { stdout, stderr } = await exec(command);
if (stderr) {
throw new Error(stderr);
@ -20,5 +20,11 @@ export const doWebpackBuildInjectable = getInjectable({
logSuccess(stdout);
};
return async () => {
await execWithResultHandling("webpack");
await execWithResultHandling("linkable-push");
};
},
});