diff --git a/ChangeLog b/ChangeLog index 1e5ba8fc..028ee029 100644 --- a/ChangeLog +++ b/ChangeLog @@ -127,6 +127,8 @@ in any position in anyLoadOnLoad function. * Changed default ip to null so IP would be geted from config.json only if it setted up. +* Fixed bug with starting node from other then projects dir. + 2012.10.01, Version 0.1.7 diff --git a/cloudcmd.js b/cloudcmd.js index a710a596..77dd3980 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -1,8 +1,6 @@ (function(){ "use strict"; - global.cloudcmd = {}; - var DIR = __dirname + '/', main = require(DIR + 'lib/server/main'), diff --git a/lib/server/main.js b/lib/server/main.js index 08c43524..dec323a9 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -23,7 +23,8 @@ global.cloudcmd = {}, /* Constants */ - exports.DIR = DIR = process.cwd() + '/', + /* current dir + 2 levels up */ + exports.DIR = DIR = __dirname + '/../../', exports.LIBDIR = LIBDIR = DIR + 'lib/', exports.SRVDIR = SRVDIR = LIBDIR + 'server/', exports.WIN32 = isWin32(); @@ -52,7 +53,7 @@ /* Needed Modules */ exports.util = Util = require(LIBDIR + 'util'), - exports.zlib = mrequire('zlib'), + exports.zlib = mrequire('zlib'), /* Main Information */ exports.config = rootrequire('config'); @@ -76,7 +77,6 @@ exports.socket = srvrequire('socket'), exports.update = srvrequire('update'), exports.minify = srvrequire('minify').Minify; - /* * second initializing after all modules load, so global var is * totally filled of all information that should know all modules diff --git a/lib/server/minify.js b/lib/server/minify.js index e612e7db..1b886192 100644 --- a/lib/server/minify.js +++ b/lib/server/minify.js @@ -4,11 +4,11 @@ "use strict"; var main = global.cloudcmd.main, - SRVDIR = main.SRVDIR; + DIR = main.DIR; exports.Minify = { /* pathes to directories */ - INDEX :'index.html', + INDEX : DIR + 'index.html', /* приватный переключатель минимизации */ _allowed :{ css : true, @@ -62,24 +62,30 @@ * in nodester) we can not write * minified versions */ - this.MinFolder = '/' + lMinify.MinFolder; + this.MinFolder = lMinify.MinFolder; - var lOptimizeParams = []; + var lOptimizeParams = [], + lStyleCSS = DIR + 'css/style.css', + lResetCSS = DIR + 'css/reset.css'; if (this._allowed.js) { - lOptimizeParams.push('client.js'); + lOptimizeParams.push(DIR + 'client.js'); } if (this._allowed.html) lOptimizeParams.push(this.INDEX); if (this._allowed.css) { - lOptimizeParams.push({ - './css/style.css' : this._allowed.img - }); + var lStyles = []; - lOptimizeParams.push({ - './css/reset.css': this._allowed.img - }); + lStyles[0] = {}; + lStyles[0][lStyleCSS] = this._allowed.img; + lStyles[1] = {}; + lStyles[1][lResetCSS] = this._allowed.img; + + lOptimizeParams.push(lStyles[0]); + lOptimizeParams.push(lStyles[1]); + + lOptimizeParams.push(); } if (lOptimizeParams.length) diff --git a/lib/server/update.js b/lib/server/update.js index c5f4c6f5..a1208d08 100644 --- a/lib/server/update.js +++ b/lib/server/update.js @@ -2,13 +2,21 @@ (function(){ "use strict"; - + var main = global.cloudcmd.main, mainpackage = main.mainpackage, - exec = main.child_process.exec; + exec = main.child_process.exec, + DIR = main.DIR; exports.get = function(){ - exec('git pull', pull); + var lPull = function(){ + exec('git pull', pull); + }; + + if( process.cwd === DIR ) + lPull(); + else + exec('cd ' + DIR, lPull); }; /** @@ -26,7 +34,7 @@ } else pStdout = 'Cloud Commander is up to date.'; - console.log( process.cwd() ); + console.log(DIR); if(mainpackage) pStdout = 'Version ' + mainpackage.version + '\n' + pStdout; } diff --git a/server.js b/server.js index 82e64e5c..8cb3202d 100644 --- a/server.js +++ b/server.js @@ -56,17 +56,15 @@ Server :{}, /* КОНСТАНТЫ */ - INDEX : 'index.html' + INDEX : __dirname + '/' + 'index.html' }, - DirPath = '/', OK = 200, - - DIR = process.cwd() + '/', - main = require(DIR + 'lib/server/main'), + main = global.cloudcmd.main, + DIR = main.Dir, LIBDIR = main.LIBDIR, SRVDIR = main.SRVDIR, @@ -402,7 +400,7 @@ * загружаем сжатый html-файл в дальнейшем */ CloudServer.INDEX = (CloudServer.Minify._allowed.html ? - '.' + CloudServer.Minify.MinFolder + 'index.min.html' + CloudServer.Minify.MinFolder + 'index.min.html' : CloudServer.INDEX); /* @@ -581,7 +579,9 @@ /* если браузер поддерживает gzip-сжатие - сжимаем данные*/ if(CloudServer.Gzip){ - Zlib.gzip(lList,CloudServer.getGzipDataFunc(lHeader,CloudServer.INDEX)); + var lGzipCB = CloudServer.getGzipDataFunc(lHeader, CloudServer.INDEX); + + Zlib.gzip(lList, lGzipCB); } /* если не поддерживаеться - отсылаем данные без сжатия*/ else