Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Safer cache directory creation (fixes #2)
On non-windows systems, the temp directory is global. So it is possible to get into situations where there are permissions issues with the cache. To workaround this (in a cheap way), the "v8-compile-cache" directory is suffixed with the user's uid. The uid is only available in POSIX systems, which mostly lines up with the global temp directory systems. In case this fails, any error when creating the cache dir or lock file, will just end silently.
- Loading branch information
Showing
2 changed files
with
43 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const os = require('os'); | ||
const tap = require('tap'); | ||
|
||
process.env.DISABLE_V8_COMPILE_CACHE = 1; | ||
const getCacheDir = require('..').__TEST__.getCacheDir; | ||
|
||
tap.test('getCacheDir', t => { | ||
const cacheDir = getCacheDir(); | ||
const parts = cacheDir.split(os.tmpdir()); | ||
const nameParts = parts[1].split(path.sep); | ||
|
||
t.match(nameParts[1], /^v8-compile-cache(-\d+)?$/); | ||
t.equal(nameParts[2], process.versions.v8); | ||
|
||
t.done(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters