mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
chore(cloudcmd) es2018-ify
This commit is contained in:
parent
d3b965ec38
commit
a232da999d
9 changed files with 31 additions and 27 deletions
|
|
@ -5,7 +5,7 @@
|
|||
const Info = require('../package');
|
||||
const DIR_SERVER = '../server/';
|
||||
|
||||
const promisify = require('es6-promisify').promisify;
|
||||
const {promisify} = require('util');
|
||||
const wraptile = require('wraptile');
|
||||
|
||||
const exit = require(DIR_SERVER + 'exit');
|
||||
|
|
@ -241,9 +241,7 @@ function readConfig(name) {
|
|||
mode: 'json'
|
||||
});
|
||||
|
||||
const result = tryCatch(readjsonSync, name);
|
||||
const error = result[0];
|
||||
const data = result[1];
|
||||
const [error, data] = tryCatch(readjsonSync, name);
|
||||
|
||||
if (error)
|
||||
return exit(error.message);
|
||||
|
|
|
|||
|
|
@ -123,7 +123,6 @@
|
|||
"deepword": "^3.0.0",
|
||||
"dword": "^7.0.0",
|
||||
"edward": "^7.0.0",
|
||||
"es6-promisify": "^6.0.0",
|
||||
"execon": "^1.2.0",
|
||||
"express": "^4.13.0",
|
||||
"files-io": "^2.0.0",
|
||||
|
|
@ -180,6 +179,7 @@
|
|||
"domtokenlist-shim": "^1.2.0",
|
||||
"emitify": "^3.0.2",
|
||||
"es6-promise": "^4.0.5",
|
||||
"es6-promisify": "^6.0.0",
|
||||
"eslint": "^5.0.0",
|
||||
"eslint-plugin-node": "^7.0.0",
|
||||
"extract-text-webpack-plugin": "^4.0.0-alpha.0",
|
||||
|
|
|
|||
|
|
@ -49,8 +49,10 @@ const clean = (a) => a.filter(notEmpty);
|
|||
module.exports = (params) => {
|
||||
const p = params || {};
|
||||
const options = p.config || {};
|
||||
const plugins = p.plugins;
|
||||
const modules = p.modules;
|
||||
const {
|
||||
modules,
|
||||
plugins,
|
||||
} = p;
|
||||
|
||||
const keys = Object.keys(options);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ const names = fs.readdirSync(columnsDir)
|
|||
|
||||
const columns = readFilesSync(columnsDir, names, 'utf8');
|
||||
|
||||
module.exports = Object.assign(
|
||||
columns,
|
||||
defaultColumns
|
||||
);
|
||||
module.exports = {
|
||||
...columns,
|
||||
...defaultColumns,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ const DIR = DIR_SERVER + '../';
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const Emitter = require('events');
|
||||
const {promisify} = require('util');
|
||||
const {homedir} = require('os');
|
||||
|
||||
const exit = require(DIR_SERVER + 'exit');
|
||||
const CloudFunc = require(DIR_COMMON + 'cloudfunc');
|
||||
|
|
@ -14,7 +16,6 @@ const CloudFunc = require(DIR_COMMON + 'cloudfunc');
|
|||
const currify = require('currify');
|
||||
const wraptile = require('wraptile');
|
||||
const squad = require('squad');
|
||||
const promisify = require('es6-promisify').promisify;
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const pullout = promisify(require('pullout'));
|
||||
const ponse = require('ponse');
|
||||
|
|
@ -23,7 +24,7 @@ const jju = require('jju');
|
|||
const writejson = require('writejson');
|
||||
const tryCatch = require('try-catch');
|
||||
const criton = require('criton');
|
||||
const HOME = require('os').homedir();
|
||||
const HOME = homedir();
|
||||
|
||||
const manageConfig = squad(traverse, cryptoPass);
|
||||
const save = promisify(_save);
|
||||
|
|
@ -47,14 +48,16 @@ const readjsonSync = (name) => {
|
|||
const rootConfig = readjsonSync(ConfigPath);
|
||||
const key = (a) => Object.keys(a).pop();
|
||||
|
||||
const result = tryCatch(readjsonSync, ConfigHome);
|
||||
const error = result[0];
|
||||
const configHome = result[1];
|
||||
const [error, configHome] = tryCatch(readjsonSync, ConfigHome);
|
||||
|
||||
if (error && error.code !== 'ENOENT')
|
||||
exit(`cloudcmd --config ${ConfigHome}: ${error.message}`);
|
||||
|
||||
const config = Object.assign({}, rootConfig, configHome);
|
||||
const config = {
|
||||
...rootConfig,
|
||||
...configHome,
|
||||
};
|
||||
|
||||
const connectionWraped = wraptile(connection);
|
||||
|
||||
module.exports = manage;
|
||||
|
|
@ -222,9 +225,10 @@ function cryptoPass(json) {
|
|||
|
||||
const password = criton(json.password, algo);
|
||||
|
||||
return Object.assign({}, json, {
|
||||
return {
|
||||
...json,
|
||||
password,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function check(socket, auth) {
|
||||
|
|
|
|||
|
|
@ -80,9 +80,10 @@ module.exports = (options, fn) => {
|
|||
});
|
||||
|
||||
const url = `${importUrl}/distribute?${query}`;
|
||||
const socket = io.connect(url, Object.assign({}, {
|
||||
const socket = io.connect(url, {
|
||||
...options,
|
||||
rejectUnauthorized: false,
|
||||
}, options));
|
||||
});
|
||||
|
||||
const superFn = wrapApply(fn, socket.close.bind(socket));
|
||||
const colorUrl = getColorUrl(importUrl, name);
|
||||
|
|
|
|||
|
|
@ -21,9 +21,10 @@ const CloudFunc = require(DIR_COMMON + 'cloudfunc');
|
|||
const prefix = squad(prefixer, apart(config, 'prefix'));
|
||||
|
||||
const sendIndex = (params, data) => {
|
||||
const ponseParams = Object.assign({}, params, {
|
||||
const ponseParams = {
|
||||
...params,
|
||||
name: 'index.html'
|
||||
});
|
||||
};
|
||||
|
||||
ponse.send(data, ponseParams);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const t = require('table');
|
||||
const table = t.table;
|
||||
const {table} = t;
|
||||
const getBorderCharacters = t.getBorderCharacters;
|
||||
|
||||
module.exports = (config) => {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ function getTerminal(term, arg) {
|
|||
if (!term)
|
||||
return noop;
|
||||
|
||||
const result = tryCatch(require, config('terminalPath'));
|
||||
const e = result[0];
|
||||
const terminalModule = result[1];
|
||||
const [e, terminalModule] = tryCatch(require, config('terminalPath'));
|
||||
|
||||
if (!e && !arg)
|
||||
return terminalModule;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue