diff --git a/hak/matrix-seshat/build.ts b/hak/matrix-seshat/build.ts index a2a8bbb4..2dbde84b 100644 --- a/hak/matrix-seshat/build.ts +++ b/hak/matrix-seshat/build.ts @@ -19,31 +19,14 @@ import childProcess from "child_process"; import HakEnv from "../../scripts/hak/hakEnv"; import { DependencyInfo } from "../../scripts/hak/dep"; -export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { - const env = hakEnv.makeGypEnv(); - - if (!hakEnv.isHost()) { - env.CARGO_BUILD_TARGET = hakEnv.getTargetId(); - } - - console.log("Running yarn install"); - await new Promise((resolve, reject) => { - const proc = childProcess.spawn("yarn" + (hakEnv.isWin() ? ".cmd" : ""), ["install"], { - cwd: moduleInfo.moduleBuildDir, - env, - shell: true, - stdio: "inherit", - }); - proc.on("exit", (code) => { - code ? reject(code) : resolve(); - }); - }); - - const buildTarget = hakEnv.wantsStaticSqlCipher() ? "build-bundled" : "build"; - - console.log("Running yarn build"); - await new Promise((resolve, reject) => { - const proc = childProcess.spawn("yarn" + (hakEnv.isWin() ? ".cmd" : ""), ["run", buildTarget], { +function run( + moduleInfo: DependencyInfo, + cmd: string, + args: string[], + env: Record, +): Promise { + return new Promise((resolve, reject) => { + const proc = childProcess.spawn(cmd, args, { cwd: moduleInfo.moduleBuildDir, env, shell: true, @@ -54,3 +37,20 @@ export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Prom }); }); } + +export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { + const env = hakEnv.makeGypEnv(); + + if (!hakEnv.isHost()) { + env.CARGO_BUILD_TARGET = hakEnv.getTargetId(); + } + const yarnCmd = "yarn" + (hakEnv.isWin() ? ".cmd" : ""); + + console.log("Running yarn install"); + await run(moduleInfo, yarnCmd, ["install"], env); + + const buildTarget = hakEnv.wantsStaticSqlCipher() ? "build-bundled" : "build"; + + console.log("Running yarn build"); + await run(moduleInfo, yarnCmd, ["run", buildTarget], env); +}