Skip to content

Commit

Permalink
Add arch to cache directory
Browse files Browse the repository at this point in the history
  • Loading branch information
yungsters committed Jul 19, 2023
1 parent 454af0b commit 972c039
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# `v8-module-cache` Changelog

## Next

* Fix segmentation fault with Rosetta on Apple Silicon.

## 2021-03-05, Version 2.3.0

* Fix use require.main instead of module.parent [#34](https://github.com/zertosh/v8-compile-cache/pull/34).
Expand Down
4 changes: 3 additions & 1 deletion v8-compile-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,14 @@ function getCacheDir() {
const dirname = typeof process.getuid === 'function'
? 'v8-compile-cache-' + process.getuid()
: 'v8-compile-cache';
// Avoid cache incompatibility issues with Rosetta on Apple Silicon.
const arch = process.arch;
const version = typeof process.versions.v8 === 'string'
? process.versions.v8
: typeof process.versions.chakracore === 'string'
? 'chakracore-' + process.versions.chakracore
: 'node-' + process.version;
const cacheDir = path.join(os.tmpdir(), dirname, version);
const cacheDir = path.join(os.tmpdir(), dirname, arch, version);
return cacheDir;
}

Expand Down

0 comments on commit 972c039

Please sign in to comment.