From cc7585bbc2aa35bad0074fa9f579a19e54132dc6 Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 22 Oct 2019 11:39:00 -0500 Subject: [PATCH] Port onigasm fix for PHP --- scripts/build.ts | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/scripts/build.ts b/scripts/build.ts index ca73b55d..ab9c1269 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -341,19 +341,25 @@ class Builder { ]); }); - // TODO: fix onigasm dep - // # onigasm 2.2.2 has a bug that makes it broken for PHP files so use 2.2.1. - // # https://github.com/NeekSandhu/onigasm/issues/17 - // function fix-onigasm() { - // local onigasmPath="${buildPath}/node_modules/onigasm-umd" - // rm -rf "${onigasmPath}" - // git clone "https://github.com/alexandrudima/onigasm-umd" "${onigasmPath}" - // cd "${onigasmPath}" && yarn && yarn add --dev onigasm@2.2.1 && yarn package - // mkdir "${onigasmPath}-temp" - // mv "${onigasmPath}/"{release,LICENSE} "${onigasmPath}-temp" - // rm -rf "${onigasmPath}" - // mv "${onigasmPath}-temp" "${onigasmPath}" - // } + // onigasm 2.2.2 has a bug that makes it broken for PHP files so use 2.2.1. + // https://github.com/NeekSandhu/onigasm/issues/17 + await this.task("Applying onigasm PHP fix", async () => { + const onigasmPath = path.join(finalBuildPath, "node_modules/onigasm-umd"); + const onigasmTmpPath = `${onigasmPath}-temp`; + await Promise.all([ + fs.remove(onigasmPath), + fs.mkdir(onigasmTmpPath), + ]); + await util.promisify(cp.exec)(`git clone "https://github.com/alexandrudima/onigasm-umd" "${onigasmPath}"`); + await util.promisify(cp.exec)("yarn", { cwd: onigasmPath }); + await util.promisify(cp.exec)("yarn add --dev onigasm@2.2.1", { cwd: onigasmPath }); + await util.promisify(cp.exec)("yarn package", { cwd: onigasmPath }); + await Promise.all(["release", "LICENSE", "package.json"].map((fileName) => { + return fs.copy(path.join(onigasmPath, fileName), path.join(onigasmTmpPath, fileName)); + })); + await fs.remove(onigasmPath); + await fs.move(onigasmTmpPath, onigasmPath); + }); this.log(`Final build: ${finalBuildPath}`); }