mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore: lint
This commit is contained in:
parent
8e25a02568
commit
88da092fdb
38 changed files with 125 additions and 124 deletions
|
|
@ -74,26 +74,26 @@ module.exports = {
|
|||
},
|
||||
entry: {
|
||||
cloudcmd: `${dir}/cloudcmd.js`,
|
||||
[modules + '/edit']: `${dirModules}/edit.js`,
|
||||
[modules + '/edit-file']: `${dirModules}/edit-file.js`,
|
||||
[modules + '/edit-file-vim']: `${dirModules}/edit-file-vim.js`,
|
||||
[modules + '/edit-names']: `${dirModules}/edit-names.js`,
|
||||
[modules + '/edit-names-vim']: `${dirModules}/edit-names-vim.js`,
|
||||
[modules + '/menu']: `${dirModules}/menu.js`,
|
||||
[modules + '/view']: `${dirModules}/view/index.js`,
|
||||
[modules + '/help']: `${dirModules}/help.js`,
|
||||
[modules + '/markdown']: `${dirModules}/markdown.js`,
|
||||
[modules + '/config']: `${dirModules}/config/index.js`,
|
||||
[modules + '/contact']: `${dirModules}/contact.js`,
|
||||
[modules + '/upload']: `${dirModules}/upload.js`,
|
||||
[modules + '/operation']: `${dirModules}/operation/index.js`,
|
||||
[modules + '/konsole']: `${dirModules}/konsole.js`,
|
||||
[modules + '/terminal']: `${dirModules}/terminal.js`,
|
||||
[modules + '/terminal-run']: `${dirModules}/terminal-run.js`,
|
||||
[modules + '/cloud']: `${dirModules}/cloud.js`,
|
||||
[modules + '/user-menu']: `${dirModules}/user-menu/index.js`,
|
||||
[modules + '/polyfill']: `${dirModules}/polyfill.js`,
|
||||
[modules + '/command-line']: `${dirModules}/command-line.js`,
|
||||
[`${modules}/edit`]: `${dirModules}/edit.js`,
|
||||
[`${modules}/edit-file`]: `${dirModules}/edit-file.js`,
|
||||
[`${modules}/edit-file-vim`]: `${dirModules}/edit-file-vim.js`,
|
||||
[`${modules}/edit-names`]: `${dirModules}/edit-names.js`,
|
||||
[`${modules}/edit-names-vim`]: `${dirModules}/edit-names-vim.js`,
|
||||
[`${modules}/menu`]: `${dirModules}/menu.js`,
|
||||
[`${modules}/view`]: `${dirModules}/view/index.js`,
|
||||
[`${modules}/help`]: `${dirModules}/help.js`,
|
||||
[`${modules}/markdown`]: `${dirModules}/markdown.js`,
|
||||
[`${modules}/config`]: `${dirModules}/config/index.js`,
|
||||
[`${modules}/contact`]: `${dirModules}/contact.js`,
|
||||
[`${modules}/upload`]: `${dirModules}/upload.js`,
|
||||
[`${modules}/operation`]: `${dirModules}/operation/index.js`,
|
||||
[`${modules}/konsole`]: `${dirModules}/konsole.js`,
|
||||
[`${modules}/terminal`]: `${dirModules}/terminal.js`,
|
||||
[`${modules}/terminal-run`]: `${dirModules}/terminal-run.js`,
|
||||
[`${modules}/cloud`]: `${dirModules}/cloud.js`,
|
||||
[`${modules}/user-menu`]: `${dirModules}/user-menu/index.js`,
|
||||
[`${modules}/polyfill`]: `${dirModules}/polyfill.js`,
|
||||
[`${modules}/command-line`]: `${dirModules}/command-line.js`,
|
||||
},
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ async function main() {
|
|||
}
|
||||
|
||||
async function validateRoot(root, config) {
|
||||
const validate = await simport(DIR_SERVER + 'validate.js');
|
||||
const validate = await simport(`${DIR_SERVER}validate.js`);
|
||||
validate.root(root, config);
|
||||
|
||||
if (root === '/')
|
||||
|
|
@ -269,7 +269,7 @@ function version() {
|
|||
}
|
||||
|
||||
async function start(options, config) {
|
||||
const SERVER = DIR_SERVER + 'server.mjs';
|
||||
const SERVER = `${DIR_SERVER}server.mjs`;
|
||||
|
||||
if (!args.server)
|
||||
return;
|
||||
|
|
@ -326,7 +326,7 @@ async function help() {
|
|||
|
||||
function repl() {
|
||||
console.log('REPL mode enabled (telnet localhost 1337)');
|
||||
require(DIR_SERVER + 'repl');
|
||||
require(`${DIR_SERVER}repl`);
|
||||
}
|
||||
|
||||
async function checkUpdate() {
|
||||
|
|
@ -342,7 +342,7 @@ async function showUpdateInfo(version) {
|
|||
|
||||
const chalk = await simport('chalk');
|
||||
|
||||
const latestVersion = chalk.green.bold('v' + version);
|
||||
const latestVersion = chalk.green.bold(`v${version}`);
|
||||
const latest = `update available: ${latestVersion}`;
|
||||
const current = chalk.dim(`(current: v${Info.version})`);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ async function replaceVersion(name, version, versionNew) {
|
|||
if (error)
|
||||
return console.error(error);
|
||||
|
||||
console.log('done: ' + name);
|
||||
console.log(`done: ${name}`);
|
||||
}
|
||||
|
||||
async function cl() {
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ function CloudCmdProto(DOM) {
|
|||
|
||||
async function loadStyle() {
|
||||
const {prefix} = CloudCmd;
|
||||
const name = prefix + '/dist/cloudcmd.common.css';
|
||||
const name = `${prefix}/dist/cloudcmd.common.css`;
|
||||
|
||||
await load.css(name);
|
||||
}
|
||||
|
|
@ -303,7 +303,7 @@ function CloudCmdProto(DOM) {
|
|||
async function ajaxLoad(path, options = {}, panel) {
|
||||
const {RESTful} = DOM;
|
||||
|
||||
CloudCmd.log('reading dir: "' + path + '";');
|
||||
CloudCmd.log(`reading dir: "${path}";`);
|
||||
|
||||
const dirStorage = CloudCmd.config('dirStorage');
|
||||
const json = dirStorage && await Storage.getJson(path);
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ module.exports.getCurrentDirName = () => {
|
|||
.replace(/\/$/, '');
|
||||
|
||||
const substr = href.substr(href, href.lastIndexOf('/'));
|
||||
const ret = href.replace(substr + '/', '') || '/';
|
||||
const ret = href.replace(`${substr}/`, '') || '/';
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -72,6 +72,6 @@ function uploadFile(url, data) {
|
|||
}
|
||||
|
||||
function uploadDir(url) {
|
||||
return DOM.load.put(url + '?dir');
|
||||
return DOM.load.put(`${url}?dir`);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ module.exports.getByTag = (tag, element = document) => {
|
|||
* @param Id - id
|
||||
*/
|
||||
module.exports.getById = (id, element = document) => {
|
||||
return element.querySelector('#' + id);
|
||||
return element.querySelector(`#${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ function EventsProto() {
|
|||
switch(type) {
|
||||
default:
|
||||
if (!type.endsWith('element'))
|
||||
throw Error('unknown eventName: ' + type);
|
||||
throw Error(`unknown eventName: ${type}`);
|
||||
|
||||
parseArgs(
|
||||
args[EVENT_NAME],
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ const FILES_JSON = 'config|modules';
|
|||
const FILES_HTML = 'file|path|link|pathLink|media';
|
||||
const FILES_HTML_ROOT = 'view/media-tmpl|config-tmpl|upload';
|
||||
const DIR_HTML = '/tmpl/';
|
||||
const DIR_HTML_FS = DIR_HTML + 'fs/';
|
||||
const DIR_HTML_FS = `${DIR_HTML}fs/`;
|
||||
const DIR_JSON = '/json/';
|
||||
const timeout = getTimeoutOnce(2000);
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ function getPath(name, isHTML, isJSON) {
|
|||
}
|
||||
|
||||
function showError(name) {
|
||||
const str = 'Wrong file name: ' + name;
|
||||
const str = `Wrong file name: ${name}`;
|
||||
const error = Error(str);
|
||||
|
||||
throw error;
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ module.exports.setProgress = (value, title) => {
|
|||
if (!element)
|
||||
return Images;
|
||||
|
||||
element.setAttribute(DATA, value + '%');
|
||||
element.setAttribute(DATA, `${value}%`);
|
||||
|
||||
if (title)
|
||||
element.title = title;
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ module.exports.promptNewFile = async () => {
|
|||
async function promptNew(typeName) {
|
||||
const {Dialog} = DOM;
|
||||
const dir = DOM.getCurrentDirPath();
|
||||
const msg = 'New ' + typeName || 'File';
|
||||
const msg = `New ${typeName}` || 'File';
|
||||
const getName = () => {
|
||||
const name = DOM.getCurrentName();
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ module.exports.getCurrentDirName = () => {
|
|||
.replace(/\/$/, '');
|
||||
|
||||
const substr = href.substr(href, href.lastIndexOf('/'));
|
||||
const ret = href.replace(substr + '/', '') || '/';
|
||||
const ret = href.replace(`${substr}/`, '') || '/';
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
|
@ -457,7 +457,7 @@ module.exports.getFilenames = (files) => {
|
|||
* check storage hash
|
||||
*/
|
||||
module.exports.checkStorageHash = async (name) => {
|
||||
const nameHash = name + '-hash';
|
||||
const nameHash = `${name}-hash`;
|
||||
|
||||
if (typeof name !== 'string')
|
||||
throw Error('name should be a string!');
|
||||
|
|
@ -486,8 +486,8 @@ module.exports.saveDataToStorage = async (name, data, hash) => {
|
|||
|
||||
hash = hash || await DOM.loadCurrentHash();
|
||||
|
||||
const nameHash = name + '-hash';
|
||||
const nameData = name + '-data';
|
||||
const nameHash = `${name}-hash`;
|
||||
const nameData = `${name}-data`;
|
||||
|
||||
await Storage.set(nameHash, hash);
|
||||
await Storage.set(nameData, data);
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ module.exports.Markdown = {
|
|||
read: async (url) => {
|
||||
return await sendRequest({
|
||||
method: 'GET',
|
||||
url: '/markdown' + url,
|
||||
url: `/markdown${url}`,
|
||||
imgPosition,
|
||||
notLog: true,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ module.exports = function setCurrentByChar(char, charStore) {
|
|||
let i = 0;
|
||||
|
||||
const escapeChar = escapeRegExp(char);
|
||||
const regExp = new RegExp('^' + escapeChar + '.*$', 'i');
|
||||
const regExp = new RegExp(`^${escapeChar}.*$`, 'i');
|
||||
const {files} = Info;
|
||||
const chars = charStore();
|
||||
const n = chars.length;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ global.DOM = getDOM();
|
|||
const {
|
||||
_next,
|
||||
_previous,
|
||||
} = require(dir + 'find');
|
||||
} = require(`${dir}find`);
|
||||
|
||||
test('cloudcmd: client: vim: _next', (t) => {
|
||||
const result = _next(1, 2);
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ test('cloudcmd: client: key: N', (t) => {
|
|||
findPrevious,
|
||||
});
|
||||
|
||||
const vim = reRequire(dir + 'vim');
|
||||
const vim = reRequire(`${dir}vim`);
|
||||
const event = {};
|
||||
|
||||
vim('N', event);
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ const getPanel = (side) => {
|
|||
if (!itype.string(side))
|
||||
return side;
|
||||
|
||||
return DOM.getByDataName('js-' + side);
|
||||
return DOM.getByDataName(`js-${side}`);
|
||||
};
|
||||
|
||||
module.exports.setOnPanel = (side) => {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ module.exports.init = async () => {
|
|||
[Template] = await Promise.all([
|
||||
Files.get('config-tmpl'),
|
||||
loadSocket(),
|
||||
loadCSS(prefix + '/dist/config.css'),
|
||||
loadCSS(`${prefix}/dist/config.css`),
|
||||
CloudCmd.View(),
|
||||
]);
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ function initSocket() {
|
|||
const socket = io.connect(href + prefixSocket + '/config', {
|
||||
reconnectionAttempts: Infinity,
|
||||
reconnectionDelay: ONE_MINUTE,
|
||||
path: prefix + '/socket.io',
|
||||
path: `${prefix}/socket.io`,
|
||||
});
|
||||
|
||||
const save = (data) => {
|
||||
|
|
@ -148,9 +148,9 @@ async function fillTemplate() {
|
|||
...obj
|
||||
} = input.convert(config);
|
||||
|
||||
obj[editor + '-selected'] = 'selected';
|
||||
obj[packer + '-selected'] = 'selected';
|
||||
obj[columns + '-selected'] = 'selected';
|
||||
obj[`${editor}-selected`] = 'selected';
|
||||
obj[`${packer}-selected`] = 'selected';
|
||||
obj[`${columns}-selected`] = 'selected';
|
||||
obj.configAuth = configAuth ? '' : 'hidden';
|
||||
|
||||
const innerHTML = rendy(Template, obj);
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ function getMenuData() {
|
|||
}
|
||||
|
||||
function setMsgChanged(name) {
|
||||
MSG_CHANGED = 'Do you want to save changes to ' + name + '?';
|
||||
MSG_CHANGED = `Do you want to save changes to ${name}?`;
|
||||
}
|
||||
|
||||
module.exports.isChanged = isChanged;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ function create() {
|
|||
|
||||
function checkFn(name, fn) {
|
||||
if (typeof fn !== 'function')
|
||||
throw Error(name + ' should be a function!');
|
||||
throw Error(`${name} should be a function!`);
|
||||
}
|
||||
|
||||
function initConfig(options = {}) {
|
||||
|
|
@ -104,7 +104,7 @@ const loadFiles = async (element) => {
|
|||
const prefixSocket = `${CloudCmd.prefixSocket}/${EditorName}`;
|
||||
const url = `${prefix}/${EditorName}.js`;
|
||||
|
||||
time(Name + ' load');
|
||||
time(`${Name} load`);
|
||||
|
||||
await loadJS(url);
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ const loadFiles = async (element) => {
|
|||
socketPath,
|
||||
});
|
||||
|
||||
timeEnd(Name + ' load');
|
||||
timeEnd(`${Name} load`);
|
||||
editor = ed;
|
||||
Loading = false;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -133,14 +133,14 @@ module.exports.show = (callback) => {
|
|||
};
|
||||
|
||||
const load = async () => {
|
||||
Util.time(Name + ' load');
|
||||
Util.time(`${Name} load`);
|
||||
|
||||
const prefix = getPrefix();
|
||||
const url = prefix + '/console.js';
|
||||
const url = `${prefix}/console.js`;
|
||||
const [error] = await tryToCatch(loadJS, url);
|
||||
|
||||
Loaded = true;
|
||||
Util.timeEnd(Name + ' load');
|
||||
Util.timeEnd(`${Name} load`);
|
||||
|
||||
if (error)
|
||||
return Dialog.alert(error.message, {
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ async function _uploadTo(nameModule) {
|
|||
const {name} = Info;
|
||||
|
||||
CloudCmd.execFromModule(nameModule, 'uploadFile', name, data);
|
||||
CloudCmd.log('Uploading to ' + name + '...');
|
||||
CloudCmd.log(`Uploading to ${name}...`);
|
||||
}
|
||||
|
||||
function uploadFromCloud() {
|
||||
|
|
@ -275,7 +275,7 @@ function download(type) {
|
|||
const isDir = DOM.isCurrentIsDir(file);
|
||||
const path = DOM.getCurrentPath(file);
|
||||
|
||||
CloudCmd.log('downloading file ' + path + '...');
|
||||
CloudCmd.log(`downloading file ${path}...`);
|
||||
/*
|
||||
* if we send ajax request -
|
||||
* no need in hash so we escape #
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ async function _processFiles(options, data) {
|
|||
|
||||
function checkEmpty(name, operation) {
|
||||
if (!operation)
|
||||
throw Error(name + ' could not be empty!');
|
||||
throw Error(`${name} could not be empty!`);
|
||||
}
|
||||
|
||||
function twopack(operation, type) {
|
||||
|
|
@ -487,9 +487,9 @@ async function prompt(msg, to, names) {
|
|||
msg += ' ';
|
||||
|
||||
if (names.length > 1)
|
||||
msg += n + ' file(s)';
|
||||
msg += `${n} file(s)`;
|
||||
else
|
||||
msg += '"' + name + '"';
|
||||
msg += `"${name}"`;
|
||||
|
||||
msg += ' to';
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,8 @@ module.exports = (options) => (emitter) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const [cancel] = await Dialog.confirm(error + '\n Continue?');
|
||||
const [cancel] = await Dialog.confirm(`${error}
|
||||
Continue?`);
|
||||
|
||||
if (!done && !cancel)
|
||||
return emitter.continue();
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ function check(src) {
|
|||
async function loadAll() {
|
||||
const {DIR_DIST} = CloudCmd;
|
||||
|
||||
time(Name + ' load');
|
||||
time(`${Name} load`);
|
||||
|
||||
Loading = true;
|
||||
await loadCSS(`${DIR_DIST}/view.css`);
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ module.exports.formatMsg = (msg, name, status) => {
|
|||
name = name || '';
|
||||
|
||||
if (name)
|
||||
name = '("' + name + '")';
|
||||
name = `("${name}")`;
|
||||
|
||||
return msg + ': ' + status + name;
|
||||
return `${msg}: ${status}${name}`;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -82,10 +82,10 @@ function getPathLink(url, prefix, template) {
|
|||
const isLast = i === n - 1;
|
||||
|
||||
if (i)
|
||||
path += name + '/';
|
||||
path += `${name}/`;
|
||||
|
||||
if (i && isLast) {
|
||||
lines.push(name + '/');
|
||||
lines.push(`${name}/`);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ module.exports.buildFromJSON = (params) => {
|
|||
/* сохраняем путь */
|
||||
Path(path);
|
||||
|
||||
fileTable += header + '<ul data-name="js-files" class="files">';
|
||||
fileTable += `${header}<ul data-name="js-files" class="files">`;
|
||||
|
||||
/* Если мы не в корне */
|
||||
if (path !== '/') {
|
||||
|
|
@ -178,7 +178,7 @@ module.exports.buildFromJSON = (params) => {
|
|||
});
|
||||
|
||||
const dataName = getDataName('..');
|
||||
const attribute = 'draggable="true" ' + dataName;
|
||||
const attribute = `draggable="true" ${dataName}`;
|
||||
|
||||
/* Сохраняем путь к каталогу верхнего уровня*/
|
||||
fileTable += rendy(template.file, {
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
const DIR = __dirname + '/';
|
||||
const DIR_COMMON = DIR + '../common/';
|
||||
const DIR = `${__dirname}/`;
|
||||
const DIR_COMMON = `${DIR}../common/`;
|
||||
const path = require('path');
|
||||
|
||||
const fs = require('fs');
|
||||
const cloudfunc = require(DIR_COMMON + 'cloudfunc');
|
||||
const cloudfunc = require(`${DIR_COMMON}cloudfunc`);
|
||||
|
||||
const authentication = require(DIR + 'auth');
|
||||
const authentication = require(`${DIR}auth`);
|
||||
const {
|
||||
createConfig,
|
||||
configPath,
|
||||
} = require(DIR + 'config');
|
||||
const modulas = require(DIR + 'modulas');
|
||||
} = require(`${DIR}config`);
|
||||
const modulas = require(`${DIR}modulas`);
|
||||
|
||||
const userMenu = require(DIR + 'user-menu');
|
||||
const rest = require(DIR + 'rest');
|
||||
const route = require(DIR + 'route');
|
||||
const validate = require(DIR + 'validate');
|
||||
const prefixer = require(DIR + 'prefixer');
|
||||
const terminal = require(DIR + 'terminal');
|
||||
const distribute = require(DIR + 'distribute');
|
||||
const userMenu = require(`${DIR}user-menu`);
|
||||
const rest = require(`${DIR}rest`);
|
||||
const route = require(`${DIR}route`);
|
||||
const validate = require(`${DIR}validate`);
|
||||
const prefixer = require(`${DIR}prefixer`);
|
||||
const terminal = require(`${DIR}terminal`);
|
||||
const distribute = require(`${DIR}distribute`);
|
||||
const currify = require('currify');
|
||||
|
||||
const apart = require('apart');
|
||||
|
|
@ -33,7 +33,7 @@ const dword = require('dword');
|
|||
const deepword = require('deepword');
|
||||
const nomine = require('nomine');
|
||||
const fileop = require('@cloudcmd/fileop');
|
||||
const DIR_ROOT = DIR + '../';
|
||||
const DIR_ROOT = `${DIR}../`;
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
const getDist = (isDev) => isDev ? 'dist-dev' : 'dist';
|
||||
|
|
@ -139,35 +139,35 @@ function listen({prefixSocket, socket, config}) {
|
|||
edward.listen(socket, {
|
||||
root,
|
||||
auth,
|
||||
prefixSocket: prefixSocket + '/edward',
|
||||
prefixSocket: `${prefixSocket}/edward`,
|
||||
});
|
||||
|
||||
dword.listen(socket, {
|
||||
root,
|
||||
auth,
|
||||
prefixSocket: prefixSocket + '/dword',
|
||||
prefixSocket: `${prefixSocket}/dword`,
|
||||
});
|
||||
|
||||
deepword.listen(socket, {
|
||||
root,
|
||||
auth,
|
||||
prefixSocket: prefixSocket + '/deepword',
|
||||
prefixSocket: `${prefixSocket}/deepword`,
|
||||
});
|
||||
|
||||
config('console') && konsole.listen(socket, {
|
||||
auth,
|
||||
prefixSocket: prefixSocket + '/console',
|
||||
prefixSocket: `${prefixSocket}/console`,
|
||||
});
|
||||
|
||||
fileop.listen(socket, {
|
||||
root,
|
||||
auth,
|
||||
prefix: prefixSocket + '/fileop',
|
||||
prefix: `${prefixSocket}/fileop`,
|
||||
});
|
||||
|
||||
config('terminal') && terminal(config).listen(socket, {
|
||||
auth,
|
||||
prefix: prefixSocket + '/gritty',
|
||||
prefix: `${prefixSocket}/gritty`,
|
||||
command: config('terminalCommand'),
|
||||
autoRestart: config('terminalAutoRestart'),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const {
|
|||
const {reRequire} = require('mock-require');
|
||||
|
||||
const DIR = './';
|
||||
const cloudcmdPath = DIR + 'cloudcmd';
|
||||
const cloudcmdPath = `${DIR}cloudcmd`;
|
||||
|
||||
const cloudcmd = require(cloudcmdPath);
|
||||
const {request} = require('serve-once')(cloudcmd, {
|
||||
|
|
@ -94,7 +94,7 @@ test('cloudcmd: replaceDist', (t) => {
|
|||
|
||||
test('cloudcmd: replaceDist: !isDev', (t) => {
|
||||
const url = '/dist/hello';
|
||||
const cloudcmdPath = DIR + 'cloudcmd';
|
||||
const cloudcmdPath = `${DIR}cloudcmd`;
|
||||
|
||||
const reset = cleanNodeEnv();
|
||||
const {_replaceDist} = reRequire(cloudcmdPath);
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
const DIR_SERVER = __dirname + '/';
|
||||
const DIR_SERVER = `${__dirname}/`;
|
||||
const DIR_COMMON = '../common/';
|
||||
const path = require('path');
|
||||
|
||||
const fs = require('fs');
|
||||
const Emitter = require('events');
|
||||
const {homedir} = require('os');
|
||||
const exit = require(DIR_SERVER + 'exit');
|
||||
const exit = require(`${DIR_SERVER}exit`);
|
||||
|
||||
const CloudFunc = require(DIR_COMMON + 'cloudfunc');
|
||||
const CloudFunc = require(`${DIR_COMMON}cloudfunc`);
|
||||
const currify = require('currify');
|
||||
|
||||
const wraptile = require('wraptile');
|
||||
|
|
@ -21,7 +21,7 @@ const jju = require('jju');
|
|||
const writejson = require('writejson');
|
||||
const tryCatch = require('try-catch');
|
||||
const criton = require('criton');
|
||||
const DIR = DIR_SERVER + '../';
|
||||
const DIR = `${DIR_SERVER}../`;
|
||||
const HOME = homedir();
|
||||
|
||||
const resolve = Promise.resolve.bind(Promise);
|
||||
|
|
@ -146,7 +146,7 @@ function _connection(manage, socket) {
|
|||
function listen(manage, sock, auth) {
|
||||
const prefix = manage('prefixSocket');
|
||||
|
||||
sock.of(prefix + '/config')
|
||||
sock.of(`${prefix}/config`)
|
||||
.on('connection', (socket) => {
|
||||
if (!manage('auth'))
|
||||
return connection(manage, socket);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const {
|
|||
createConfig,
|
||||
_cryptoPass,
|
||||
} = require(configPath);
|
||||
const {apiURL} = require(root + 'common/cloudfunc');
|
||||
const {apiURL} = require(`${root}common/cloudfunc`);
|
||||
|
||||
const fixture = require('./config.fixture');
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ threadIt.init();
|
|||
// warm up
|
||||
parse('');
|
||||
|
||||
const DIR_ROOT = __dirname + '/../../';
|
||||
const DIR_ROOT = `${__dirname}/../../`;
|
||||
|
||||
module.exports = callbackify(async (name, rootDir, request) => {
|
||||
check(name, request);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module.exports = (value) => {
|
|||
return '';
|
||||
|
||||
if (value && !value.includes('/'))
|
||||
return '/' + value;
|
||||
return `/${value}`;
|
||||
|
||||
return value;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
const DIR = '../';
|
||||
const DIR_COMMON = DIR + '../common/';
|
||||
const DIR_COMMON = `${DIR}../common/`;
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const root = require(DIR + 'root');
|
||||
const CloudFunc = require(DIR_COMMON + 'cloudfunc');
|
||||
const markdown = require(DIR + 'markdown');
|
||||
const root = require(`${DIR}root`);
|
||||
const CloudFunc = require(`${DIR_COMMON}cloudfunc`);
|
||||
const markdown = require(`${DIR}markdown`);
|
||||
const info = require('./info');
|
||||
|
||||
const jaguar = require('jaguar');
|
||||
|
|
@ -36,7 +36,7 @@ const UserError = (msg) => {
|
|||
|
||||
module.exports = currify((config, request, response, next) => {
|
||||
const name = ponse.getPathName(request);
|
||||
const regExp = RegExp('^' + apiURL);
|
||||
const regExp = RegExp(`^${apiURL}`);
|
||||
const is = regExp.test(name);
|
||||
|
||||
if (!is)
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ const once = require('once');
|
|||
const pipe = require('pipe-io');
|
||||
const {contentType} = require('mime-types');
|
||||
|
||||
const root = require(DIR_SERVER + 'root');
|
||||
const prefixer = require(DIR_SERVER + 'prefixer');
|
||||
const CloudFunc = require(DIR_COMMON + 'cloudfunc');
|
||||
const root = require(`${DIR_SERVER}root`);
|
||||
const prefixer = require(`${DIR_SERVER}prefixer`);
|
||||
const CloudFunc = require(`${DIR_COMMON}cloudfunc`);
|
||||
|
||||
const Columns = require(`${DIR_SERVER}/columns`);
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ const getReadDir = (config) => {
|
|||
*/
|
||||
module.exports = currify((config, options, request, response, next) => {
|
||||
const name = ponse.getPathName(request);
|
||||
const isFS = RegExp('^/$|^' + FS).test(name);
|
||||
const isFS = RegExp(`^/$|^${FS}`).test(name);
|
||||
|
||||
if (!isFS)
|
||||
return next();
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export default async (options, config) => {
|
|||
app.use(logger('dev'));
|
||||
|
||||
if (prefix)
|
||||
app.get('/', (req, res) => res.redirect(prefix + '/'));
|
||||
app.get('/', (req, res) => res.redirect(`${prefix}/`));
|
||||
|
||||
const socketServer = new Server(server, {
|
||||
path: `${prefix}/socket.io`,
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@
|
|||
const fs = require('fs');
|
||||
const tryCatch = require('try-catch');
|
||||
|
||||
const DIR = __dirname + '/../../';
|
||||
const COMMONDIR = DIR + 'common/';
|
||||
const DIR = `${__dirname}/../../`;
|
||||
const COMMONDIR = `${DIR}common/`;
|
||||
const {
|
||||
time,
|
||||
timeEnd,
|
||||
} = require(COMMONDIR + 'util');
|
||||
} = require(`${COMMONDIR}util`);
|
||||
|
||||
const CloudFuncPath = COMMONDIR + 'cloudfunc';
|
||||
const CloudFuncPath = `${COMMONDIR}cloudfunc`;
|
||||
|
||||
const CloudFunc = require(CloudFuncPath);
|
||||
|
||||
|
|
@ -20,10 +20,10 @@ const {reRequire} = require('mock-require');
|
|||
const htmlLooksLike = require('html-looks-like');
|
||||
|
||||
const readFilesSync = require('@cloudcmd/read-files-sync');
|
||||
const TMPLDIR = DIR + 'tmpl/';
|
||||
const TMPLDIR = `${DIR}tmpl/`;
|
||||
|
||||
const FS_DIR = TMPLDIR + 'fs/';
|
||||
const EXPECT_PATH = __dirname + '/cloudfunc.html';
|
||||
const FS_DIR = `${TMPLDIR}fs/`;
|
||||
const EXPECT_PATH = `${__dirname}/cloudfunc.html`;
|
||||
|
||||
const addHBS = (a) => `${a}.hbs`;
|
||||
const TMPL = [
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ const serveOnce = require('serve-once');
|
|||
const {reRequire, stopAll} = mockRequire;
|
||||
|
||||
const cloudcmdPath = '../../';
|
||||
const dir = cloudcmdPath + 'server/';
|
||||
const restPath = dir + 'rest';
|
||||
const dir = `${cloudcmdPath}server/`;
|
||||
const restPath = `${dir}rest`;
|
||||
|
||||
const {assign} = Object;
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ test('cloudcmd: rest: pack: tar: get', async (t) => {
|
|||
|
||||
const [, stream] = await once('entry', extract);
|
||||
const data = await pullout(stream);
|
||||
const file = fs.readFileSync(__dirname + '/../fixture/pack', 'utf8');
|
||||
const file = fs.readFileSync(`${__dirname}/../fixture/pack`, 'utf8');
|
||||
|
||||
t.equal(file, data, 'should pack data');
|
||||
t.end();
|
||||
|
|
@ -76,7 +76,7 @@ test('cloudcmd: rest: pack: tar: put: file', async (t) => {
|
|||
config,
|
||||
};
|
||||
|
||||
const name = String(Math.random()) + '.tar.gz';
|
||||
const name = `${Math.random()}.tar.gz`;
|
||||
|
||||
const {request} = serveOnce(cloudcmd, defaultOptions);
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ test('cloudcmd: rest: pack: tar: put: file', async (t) => {
|
|||
|
||||
const [, stream] = await once('entry', extract);
|
||||
const data = await pullout(stream, 'buffer');
|
||||
const result = fs.readFileSync(__dirname + '/../fixture/pack');
|
||||
const result = fs.readFileSync(`${__dirname}/../fixture/pack`);
|
||||
|
||||
fs.unlinkSync(`${__dirname}/../${name}`);
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ test('cloudcmd: rest: pack: tar: put: response', async (t) => {
|
|||
config,
|
||||
};
|
||||
|
||||
const name = String(Math.random()) + '.tar.gz';
|
||||
const name = `${Math.random()}.tar.gz`;
|
||||
const {body} = await request.put(`/api/v1/pack`, {
|
||||
options,
|
||||
body: getPackOptions(name),
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ const serveOnce = require('serve-once');
|
|||
const {reRequire, stopAll} = mockRequire;
|
||||
|
||||
const cloudcmdPath = '../../';
|
||||
const dir = cloudcmdPath + 'server/';
|
||||
const restPath = dir + 'rest';
|
||||
const dir = `${cloudcmdPath}server/`;
|
||||
const restPath = `${dir}rest`;
|
||||
|
||||
test('cloudcmd: rest: rename', async (t) => {
|
||||
const volume = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue