Skip to content

Commit c6a4bdc

Browse files
authored
fix: modify the value of the environment variable TMPDIR (#53)
1 parent a716005 commit c6a4bdc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,15 @@ function lifecycle (pkg, stage, wd, opts) {
9999

100100
// 'nobody' typically doesn't have permission to write to /tmp
101101
// even if it's never used, sh freaks out.
102-
if (!opts.unsafePerm) env.TMPDIR = wd
102+
if (!opts.unsafePerm) {
103+
const tmpdir = path.join(wd, 'node_modules', '.tmp')
104+
try {
105+
fs.mkdirSync(tmpdir, { recursive: true })
106+
} catch (err) {
107+
if (err.code !== 'EEXIST') throw err
108+
}
109+
env.TMPDIR = tmpdir
110+
}
103111

104112
lifecycle_(pkg, stage, wd, opts, env, (er) => {
105113
if (er) return reject(er)

0 commit comments

Comments
 (0)