Skip to content

Commit cc7585b

Browse files
committed
Port onigasm fix for PHP
1 parent 14a0cd3 commit cc7585b

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

scripts/build.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -341,19 +341,25 @@ class Builder {
341341
]);
342342
});
343343

344-
// TODO: fix onigasm dep
345-
// # onigasm 2.2.2 has a bug that makes it broken for PHP files so use 2.2.1.
346-
// # https://github.com/NeekSandhu/onigasm/issues/17
347-
// function fix-onigasm() {
348-
// local onigasmPath="${buildPath}/node_modules/onigasm-umd"
349-
// rm -rf "${onigasmPath}"
350-
// git clone "https://github.com/alexandrudima/onigasm-umd" "${onigasmPath}"
351-
// cd "${onigasmPath}" && yarn && yarn add --dev onigasm@2.2.1 && yarn package
352-
// mkdir "${onigasmPath}-temp"
353-
// mv "${onigasmPath}/"{release,LICENSE} "${onigasmPath}-temp"
354-
// rm -rf "${onigasmPath}"
355-
// mv "${onigasmPath}-temp" "${onigasmPath}"
356-
// }
344+
// onigasm 2.2.2 has a bug that makes it broken for PHP files so use 2.2.1.
345+
// https://github.com/NeekSandhu/onigasm/issues/17
346+
await this.task("Applying onigasm PHP fix", async () => {
347+
const onigasmPath = path.join(finalBuildPath, "node_modules/onigasm-umd");
348+
const onigasmTmpPath = `${onigasmPath}-temp`;
349+
await Promise.all([
350+
fs.remove(onigasmPath),
351+
fs.mkdir(onigasmTmpPath),
352+
]);
353+
await util.promisify(cp.exec)(`git clone "https://github.com/alexandrudima/onigasm-umd" "${onigasmPath}"`);
354+
await util.promisify(cp.exec)("yarn", { cwd: onigasmPath });
355+
await util.promisify(cp.exec)("yarn add --dev onigasm@2.2.1", { cwd: onigasmPath });
356+
await util.promisify(cp.exec)("yarn package", { cwd: onigasmPath });
357+
await Promise.all(["release", "LICENSE", "package.json"].map((fileName) => {
358+
return fs.copy(path.join(onigasmPath, fileName), path.join(onigasmTmpPath, fileName));
359+
}));
360+
await fs.remove(onigasmPath);
361+
await fs.move(onigasmTmpPath, onigasmPath);
362+
});
357363

358364
this.log(`Final build: ${finalBuildPath}`);
359365
}

0 commit comments

Comments
 (0)