1
1
var fs = require ( 'fs' ) ,
2
2
path = require ( 'path' ) ,
3
3
exec = require ( 'child_process' ) . exec ,
4
- cmd = process . argv [ 2 ] ;
4
+ cmd = process . argv [ 2 ] ,
5
+ dest_dir = process . argv [ 3 ] || '' ;
5
6
6
7
if ( cmd !== 'install' && cmd !== 'uninstall' ) {
7
8
console . error ( 'Unknown command: ' + cmd ) ;
@@ -26,7 +27,7 @@ function copy(src, dst, callback) {
26
27
return ;
27
28
}
28
29
29
- dst = path . join ( node_prefix , dst ) ;
30
+ dst = path . join ( dest_dir , node_prefix , dst ) ;
30
31
var dir = dst . replace ( / \/ [ ^ \/ ] * $ / , '/' ) ;
31
32
32
33
// Create directory if hasn't done this yet
@@ -42,7 +43,7 @@ function copy(src, dst, callback) {
42
43
// Remove files
43
44
function remove ( files ) {
44
45
files . forEach ( function ( file ) {
45
- file = path . join ( node_prefix , file ) ;
46
+ file = path . join ( dest_dir , node_prefix , file ) ;
46
47
queue . push ( 'rm -rf ' + file ) ;
47
48
} ) ;
48
49
}
@@ -127,9 +128,10 @@ if (cmd === 'install') {
127
128
if ( variables . node_install_npm ) {
128
129
copy ( 'deps/npm' , 'lib/node_modules/npm' ) ;
129
130
queue . push ( 'ln -sf ../lib/node_modules/npm/bin/npm-cli.js ' +
130
- path . join ( node_prefix , 'bin/npm' ) ) ;
131
+ path . join ( dest_dir , node_prefix , 'bin/npm' ) ) ;
131
132
queue . push ( [ shebang , '#!' + path . join ( node_prefix , 'bin/node' ) ,
132
- path . join ( node_prefix , 'lib/node_modules/npm/bin/npm-cli.js' ) ] ) ;
133
+ path . join ( dest_dir , node_prefix ,
134
+ 'lib/node_modules/npm/bin/npm-cli.js' ) ] ) ;
133
135
}
134
136
} else {
135
137
remove ( [
0 commit comments