Skip to content

Commit

Permalink
fix: add fallback for Mac arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Dec 30, 2021
1 parent 2c87403 commit 57f133a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- windows-latest
- macos-latest
- ubuntu-latest
- macos-11 # arm64
# - macos-11 # arm64
d:
- "ldc-1.28.0"
node:
Expand Down
12 changes: 12 additions & 0 deletions src/node/lib.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { execFile } from "child_process"
import { readFile, writeFile } from "fs/promises";
import { join } from "path"

/**
Expand All @@ -10,6 +11,17 @@ import { join } from "path"
* @throws {Promise<string | Error>} The promise is rejected with the reason for failure
*/
export async function minifyFiles(files: string[], hasComment = false): Promise<void> {
if (process.platform === "darwin" && process.arch === "arm64") {
// fallback to jasonminify due to missing ARM64 binaries
// eslint-disable-next-line @typescript-eslint/no-var-requires
const jsonminify = require("jsonminify");
files.map(async (file) => {
const jsonString = await readFile(file, 'utf8');
const minifiedJsonString = jsonminify(jsonString) as string;
await writeFile(file, minifiedJsonString);
})
}

const filesNum = files.length
if (filesNum === 0) {
return Promise.resolve()
Expand Down

0 comments on commit 57f133a

Please sign in to comment.