@@ -44,29 +44,72 @@ var rm_rf = function(path, cb) {
4444
4545console . log ( "Installing dxsync:" ) ;
4646
47- ch . exec ( "npm install https://github.com/digexp/dxsync/archive/1.0.2.tar.gz --no-optional" ,
48- function ( err ) {
47+ var cwd = process . cwd ( ) ;
48+
49+ var command = "npm install --no-optional --no-bin-links --prefix " + cwd + " https://github.com/digexp/dxsync/archive/1.0.2.tar.gz" ;
50+
51+ if ( process . platform == "win32" ) {
52+ command = "npm install --no-optional https://github.com/digexp/dxsync/archive/1.0.2.tar.gz"
53+ }
54+
55+ var cleanup = function ( ) {
56+ rm_rf ( "node_modules/dxsync/precompiled_modules/" ) ;
57+ rm_rf ( "node_modules/dxsync/precompiled_modules.zip" ) ;
58+ }
59+
60+ var cleanupWindows = function ( cb ) {
61+ ch . exec ( "npm root -g" , { } , function ( err , root ) {
62+ root = root || process . env . _ ;
63+ if ( root && fs . existsSync ( root + "\\dxsync\\package.json" ) ) {
64+ ch . exec ( 'xcopy "' + root + '\\dxsync" "' + process . cwd ( ) + '\\node_modules\\dxsync" /e /y' , function ( ) {
65+ cb && cb ( ) ;
66+ } ) ;
67+ } else {
68+ cb && cb ( ) ;
69+ }
70+ } ) ;
71+ }
72+
73+ var cleanupUnix = function ( cb ) {
74+ if ( fs . existsSync ( "lib/node_modules/dxsync/package.json" ) ) {
75+ ch . exec ( "cp -r lib/node_modules/dxsync/ node_modules/dxsync/" , function ( ) {
76+ rm_rf ( "lib/node_modules/dxsync" ) ; // ./lib/ shouldn't exist in this version of npm
77+ cb && cb ( ) ;
78+ } ) ;
79+ }
80+ }
81+
82+ cleanup ( ) ;
83+ /*ch.exec(command, { cwd: cwd },
84+ function(err, stdout, stderr) {
85+ if (stdout) {
86+ console.log(stdout);
87+ }
88+ if (stderr) {
89+ console.error(stderr);
90+ }
4991 if (err) {
5092 console.error("Error installing dxsync: " + err.message);
93+ } else if (process.platform == "win32") {
94+ cleanupWindows(cleanup);
5195 } else {
52- rm_rf ( "node_modules/dxsync/precompiled_modules/" ) ;
53- rm_rf ( "node_modules/dxsync/precompiled_modules.zip" ) ;
54-
55- setTimeout ( function ( ) {
56- console . log ( "Done!" )
57- } , 300 ) ;
96+ cleanupUnix(cleanup);
5897 }
59- } ) ;
98+ setTimeout(function() {
99+ console.log("Done!")
100+ }, 500);
101+ });*/
60102
61103// check if user-settings has been saved temporarily
62104// (for saving settings when re-installing the dashboard globally)
63- ch . exec ( "npm root -g" , function ( err , root ) {
105+ ch . exec ( "npm root -g" , { } , function ( err , root ) {
106+ root = root || process . env . _ ;
64107 if ( root ) {
65108 root = root . replace ( / \n | \r / g, "" ) ;
66109 fs . readFile ( path . resolve ( root , ".digexp-dashboard-user-settings.json" ) ,
67110 function ( err , contents ) {
68111 if ( ! err ) {
69- fs . writeFile ( path . resolve ( root , "digexp-dashboard/user-settings.json" ) ,
112+ fs . writeFile ( path . resolve ( root , "digexp-dashboard/user-settings.json" ) ,
70113 contents ) ;
71114 fs . unlink ( path . resolve ( root , ".digexp-dashboard-user-settings.json" ) )
72115 }
0 commit comments