@@ -18,6 +18,9 @@ var request = require('request')
18
18
var url = require ( 'url' )
19
19
var util = require ( './lib/util' )
20
20
var which = require ( 'which' )
21
+ var os = require ( 'os' )
22
+
23
+ console . log ( 'NPM ' , process . env . npm_config_tmp )
21
24
22
25
var originalPath = process . env . PATH
23
26
@@ -104,15 +107,17 @@ function exit(code) {
104
107
function findSuitableTempDirectory ( ) {
105
108
var now = Date . now ( )
106
109
var candidateTmpDirs = [
107
- process . env . TMPDIR || process . env . TEMP || process . env . npm_config_tmp ,
108
- '/tmp' ,
110
+ process . env . npm_config_tmp ,
111
+ os . tmpdir ( ) ,
109
112
path . join ( process . cwd ( ) , 'tmp' )
110
113
]
111
114
112
115
for ( var i = 0 ; i < candidateTmpDirs . length ; i ++ ) {
113
- var candidatePath = path . join ( candidateTmpDirs [ i ] , 'phantomjs' )
116
+ var candidatePath = candidateTmpDirs [ i ]
117
+ if ( ! candidatePath ) continue
114
118
115
119
try {
120
+ candidatePath = path . join ( path . resolve ( candidatePath ) , 'phantomjs' )
116
121
fs . mkdirsSync ( candidatePath , '0777' )
117
122
// Make double sure we have 0777 permissions; some operating systems
118
123
// default umask does not allow write by default.
@@ -127,7 +132,7 @@ function findSuitableTempDirectory() {
127
132
}
128
133
129
134
console . error ( 'Can not find a writable tmp directory, please report issue ' +
130
- 'on https://github.com/Obvious /phantomjs/issues/59 with as much ' +
135
+ 'on https://github.com/Medium /phantomjs/issues with as much ' +
131
136
'information as possible.' )
132
137
exit ( 1 )
133
138
}
0 commit comments