Skip to content

Commit f57ba31

Browse files
committed
Add arch to cache directory
1 parent 454af0b commit f57ba31

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# `v8-module-cache` Changelog
22

3+
## Next
4+
5+
* Fix segmentation fault with Rosetta on Apple Silicon [#45](https://github.com/zertosh/v8-compile-cache/pull/45).
6+
37
## 2021-03-05, Version 2.3.0
48

59
* Fix use require.main instead of module.parent [#34](https://github.com/zertosh/v8-compile-cache/pull/34).

v8-compile-cache.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,14 @@ function getCacheDir() {
319319
const dirname = typeof process.getuid === 'function'
320320
? 'v8-compile-cache-' + process.getuid()
321321
: 'v8-compile-cache';
322+
// Avoid cache incompatibility issues with Rosetta on Apple Silicon.
323+
const arch = process.arch;
322324
const version = typeof process.versions.v8 === 'string'
323325
? process.versions.v8
324326
: typeof process.versions.chakracore === 'string'
325327
? 'chakracore-' + process.versions.chakracore
326328
: 'node-' + process.version;
327-
const cacheDir = path.join(os.tmpdir(), dirname, version);
329+
const cacheDir = path.join(os.tmpdir(), dirname, arch, version);
328330
return cacheDir;
329331
}
330332

0 commit comments

Comments
 (0)