Skip to content

Commit 9776220

Browse files
committed
nan can be installed in the top level node_modules
1 parent 3fac91f commit 9776220

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tools/updatenan.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const spawn = require('child_process').spawn
2+
const existsSync = require('fs').existsSync
23

34
if (process.platform === 'win32') {
4-
spawn('powershell', ['-Command', "(Get-Content -Raw ./node_modules/nan/nan.h) -replace '#include \"nan_scriptorigin.h\"', '// #include \"nan_scriptorigin.h\"' | Out-File -Encoding Utf8 ./node_modules/nan/nan.h"], { stdio: 'inherit'})
5-
}else{
6-
spawn('sed', ['-i', '-e', 's/^#include .nan_scriptorigin\\.h./\\/\\/ #include nan_scriptorigin.h/', './node_modules/nan/nan.h'], { stdio: 'inherit'})
7-
}
8-
9-
5+
const nanPath = existsSync('./node_modules/nan/nan.h') ? './node_modules/nan/nan.h' : '../nan/nan.h'
6+
spawn('powershell', ['-Command', `(Get-Content -Raw ${nanPath}) -replace '#include \"nan_scriptorigin.h\"', '// #include \"nan_scriptorigin.h\"' | Out-File -Encoding Utf8 ${nanPath}`], { stdio: 'inherit' })
7+
} else {
8+
spawn('sed', ['-i', '-e', 's/^#include .nan_scriptorigin\\.h./\\/\\/ #include nan_scriptorigin.h/', './node_modules/nan/nan.h'], { stdio: 'inherit' })
9+
}

0 commit comments

Comments
 (0)