1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/packages/infrastructure/webpack/src/scripts/do-webpack-build.ts
Iku-turso 7114ee0e93 feat: Make webpack configuration trigger linkable-push
Previously this was done by lens-webpack-build, which is awkward for
build-scripts that watch.

Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>

Signed-off-by: Mikko Aspiala <mikko.aspiala@gmail.com>
Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
2023-05-31 14:35:37 +03:00

31 lines
924 B
TypeScript

import { getInjectable } from "@ogre-tools/injectable";
import { execInjectable } from "./exec.injectable";
import { logSuccessInjectable } from "./log-success.injectable";
import { logWarningInjectable } from "./log-warning.injectable";
export type DoWebpackBuild = () => Promise<void>;
export const doWebpackBuildInjectable = getInjectable({
id: "do-webpack-build",
instantiate: (di) => {
const exec = di.inject(execInjectable);
const logSuccess = di.inject(logSuccessInjectable);
const logWarning = di.inject(logWarningInjectable);
const execWithResultHandling = async (command: string) => {
const { stdout, stderr } = await exec(command);
if (stderr) {
logWarning(`Warning while executing "${command}": ${stderr}`);
} else if (stdout) {
logSuccess(stdout);
}
};
return async () => {
await execWithResultHandling("webpack");
};
},
});