diff --git a/lib/server/main.js b/lib/server/main.js index 7081a7be..c7184834 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -12,12 +12,15 @@ exports.path = require('path'), exports.fs = require('fs'), exports.querystring = require('querystring'), exports.child_process = require('child_process'), +exports.https = require('https'), exports.zlib = srvfunc.require('zlib'), exports.cloudfunc = srvfunc.require(LIBDIR + 'cloudfunc'), exports.util = srvfunc.require(LIBDIR + 'util'), exports.update = srvfunc.require(SRVDIR + 'update'), exports.appcache = srvfunc.require(SRVDIR + 'appcache'), +exports.auth = srvfunc.require(SRVDIR + 'auth'), exports.socket = srvfunc.require(SRVDIR + 'socket'), exports.object = srvfunc.require(SRVDIR + 'object'), -exports.config = srvfunc.require(DIR + 'config'); \ No newline at end of file +exports.config = srvfunc.require(DIR + 'config'); +exports.mainpackage = srvfunc.require(DIR + 'package'); \ No newline at end of file diff --git a/lib/server/update.js b/lib/server/update.js index 1b7828df..efa9cc98 100644 --- a/lib/server/update.js +++ b/lib/server/update.js @@ -1,13 +1,11 @@ /* module update cloud commander */ -var exec = require('child_process').exec, - packagejson = cloudRequire(process.cwd() + '/package'); +var DIR = process.cwd() + '/', + main = require(DIR + 'lib/server/main.js'), + mainpackage = main.mainpackage, + exec = main.child_process.exec; -/** - * function gets update - * @param pCallBack - */ -exports.get = function(pCallBack){ +exports.get = function(){ exec('git pull', pull); }; @@ -27,8 +25,8 @@ function pull(pError, pStdout, pStderr){ else pStdout = 'Cloud Commander is up to date.'; console.log( process.cwd() ); - if(packagejson) - pStdout = 'Version ' + packagejson.version + '\n' + pStdout; + if(mainpackage) + pStdout = 'Version ' + mainpackage.version + '\n' + pStdout; } var lExec = { @@ -37,17 +35,4 @@ function pull(pError, pStdout, pStderr){ }; console.log(lExec); -} - -/** - * function do safe require of needed module - * @param pModule - */ -function cloudRequire(pModule){ - try{ - return require(pModule); - } - catch(pError){ - return false; - } } \ No newline at end of file diff --git a/server.js b/server.js index d817627d..a306c11f 100644 --- a/server.js +++ b/server.js @@ -98,7 +98,7 @@ var CloudServer = { DIR = main.DIR, LIBDIR = main.LIBDIR, - SRVDIR = main.LIBDIR, + SRVDIR = main.SRVDIR, /* модуль для работы с путями*/ Path = main.path, @@ -472,7 +472,7 @@ CloudServer._controller = function(pReq, pRes) /* читаем основные данные о файле */ if( lQuery && lQuery.indexOf('code=') === 0){ - var lAuth = srvfunc.require(SRVDIR + 'auth'); + var lAuth = main.auth; if(lAuth) lAuth.auth(lQuery, function(){ Fs.stat(DirPath, CloudServer._stated);