mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
fix(config) configManager: totally move away from singletone
This commit is contained in:
parent
2abe7d688d
commit
b6ed7da0a7
16 changed files with 127 additions and 115 deletions
|
|
@ -6,10 +6,19 @@ const Info = require('../package');
|
|||
const DIR_SERVER = '../server/';
|
||||
|
||||
const {promisify} = require('util');
|
||||
|
||||
const wraptile = require('wraptile');
|
||||
|
||||
const exit = require(DIR_SERVER + 'exit');
|
||||
const config = require(DIR_SERVER + 'config');
|
||||
const {
|
||||
createConfig,
|
||||
configPath,
|
||||
} = require(DIR_SERVER + 'config');
|
||||
|
||||
const config = createConfig({
|
||||
configPath,
|
||||
});
|
||||
|
||||
const env = require(DIR_SERVER + 'env');
|
||||
const prefixer = require(DIR_SERVER + '/prefixer');
|
||||
|
||||
|
|
@ -208,14 +217,14 @@ function main() {
|
|||
if (args['show-config'])
|
||||
showConfig();
|
||||
|
||||
const startWraped = wraptile(start, options);
|
||||
const startWraped = wraptile(start, options, config);
|
||||
const distribute = require('../server/distribute');
|
||||
const importConfig = promisify(distribute.import);
|
||||
const caller = (fn) => fn();
|
||||
|
||||
importConfig(config)
|
||||
.then(args.save ? caller(config.save) : noop)
|
||||
.then(startWraped(options));
|
||||
.then(startWraped);
|
||||
}
|
||||
|
||||
function validateRoot(root, config) {
|
||||
|
|
@ -237,14 +246,14 @@ function version() {
|
|||
console.log('v' + Info.version);
|
||||
}
|
||||
|
||||
function start(config) {
|
||||
function start(options, config) {
|
||||
const SERVER = DIR_SERVER + 'server';
|
||||
|
||||
if (!args.server)
|
||||
return;
|
||||
|
||||
const server = require(SERVER);
|
||||
server(config);
|
||||
server(options, config);
|
||||
}
|
||||
|
||||
function port(arg) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue