11var fs = require ( 'fs' ) ,
22 path = require ( 'path' ) ,
33 exec = require ( 'child_process' ) . exec ,
4- cmd = process . argv [ 2 ] ;
4+ cmd = process . argv [ 2 ] ,
5+ dest_dir = process . argv [ 3 ] || '' ;
56
67if ( cmd !== 'install' && cmd !== 'uninstall' ) {
78 console . error ( 'Unknown command: ' + cmd ) ;
@@ -26,7 +27,7 @@ function copy(src, dst, callback) {
2627 return ;
2728 }
2829
29- dst = path . join ( node_prefix , dst ) ;
30+ dst = path . join ( dest_dir , node_prefix , dst ) ;
3031 var dir = dst . replace ( / \/ [ ^ \/ ] * $ / , '/' ) ;
3132
3233 // Create directory if hasn't done this yet
@@ -42,7 +43,7 @@ function copy(src, dst, callback) {
4243// Remove files
4344function remove ( files ) {
4445 files . forEach ( function ( file ) {
45- file = path . join ( node_prefix , file ) ;
46+ file = path . join ( dest_dir , node_prefix , file ) ;
4647 queue . push ( 'rm -rf ' + file ) ;
4748 } ) ;
4849}
@@ -127,9 +128,10 @@ if (cmd === 'install') {
127128 if ( variables . node_install_npm ) {
128129 copy ( 'deps/npm' , 'lib/node_modules/npm' ) ;
129130 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' ) ) ;
131132 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' ) ] ) ;
133135 }
134136} else {
135137 remove ( [
0 commit comments