Skip to content

Commit ff834aa

Browse files
Krinklecoreyfarrell
authored andcommitted
feat: avoid hardcoded HOME for spawn-wrap working dir (#957)
By default, spawn-wrap writes temporary files to HOME. It used to be /tmp, but it changed that to HOME to support environments that have 'noexec' flags set on their tmpfs mount. Ref istanbuljs/spawn-wrap#3. The problem with this is that nyc now no longer works in environments without a (writable) home directory (e.g. the 'nobody' user on Linux). While it is fine to fallback to HOME, it should write elsewhere if that is unavailable, and ideally in a way that doesn't require every sysadmin or end-user to hardcode some environment variable in their package.json specifically for nyc or spawn-wrap. A common way to communicate this intent is with the XDG_CACHE_HOME environment variable. Fixes #951.
1 parent 35710b1 commit ff834aa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

bin/nyc.js

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ if ([
4242
if (argv.all) nyc.addAllFiles()
4343

4444
var env = {
45+
// Support running nyc as a user without HOME (e.g. linux 'nobody'),
46+
// https://github.com/istanbuljs/nyc/issues/951
47+
SPAWN_WRAP_SHIM_ROOT: process.env.SPAWN_WRAP_SHIM_ROOT || process.env.XDG_CACHE_HOME || require('os').homedir(),
4548
NYC_CONFIG: JSON.stringify(argv),
4649
NYC_CWD: process.cwd(),
4750
NYC_ROOT_ID: nyc.rootId,

0 commit comments

Comments
 (0)