mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore: server: lint
This commit is contained in:
parent
d55b6fb393
commit
20a00481d6
4 changed files with 16 additions and 14 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const isString = (a) => typeof a === 'string';
|
||||||
const {join} = require('path');
|
const {join} = require('path');
|
||||||
const {callbackify} = require('util');
|
const {callbackify} = require('util');
|
||||||
|
|
||||||
|
|
@ -56,7 +57,7 @@ async function onPUT(request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function check(name, request) {
|
function check(name, request) {
|
||||||
if (typeof name !== 'string')
|
if (!isString(name))
|
||||||
throw Error('name should be string!');
|
throw Error('name should be string!');
|
||||||
|
|
||||||
if (!request)
|
if (!request)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const isString = (a) => typeof a === 'string';
|
||||||
|
|
||||||
module.exports = (value) => {
|
module.exports = (value) => {
|
||||||
if (typeof value !== 'string')
|
if (!isString(value))
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
if (value.length === 1)
|
if (value.length === 1)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const isFn = (a) => typeof a === 'function';
|
||||||
|
const isString = (a) => typeof a === 'string';
|
||||||
const DIR = '../';
|
const DIR = '../';
|
||||||
const DIR_COMMON = `${DIR}../common/`;
|
const DIR_COMMON = `${DIR}../common/`;
|
||||||
|
|
||||||
|
|
@ -148,7 +150,7 @@ function onGET(params, config, callback) {
|
||||||
function getPackReg(packer) {
|
function getPackReg(packer) {
|
||||||
if (packer === 'zip')
|
if (packer === 'zip')
|
||||||
return /\.zip$/;
|
return /\.zip$/;
|
||||||
|
|
||||||
return /\.tar\.gz$/;
|
return /\.tar\.gz$/;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,14 +169,11 @@ function streamPack(cmd, response, packer) {
|
||||||
function getCMD(cmd) {
|
function getCMD(cmd) {
|
||||||
if (cmd[0] === '/')
|
if (cmd[0] === '/')
|
||||||
return cmd.slice(1);
|
return cmd.slice(1);
|
||||||
|
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getMoveMsg = (names) => {
|
const getMoveMsg = (names) => formatMsg('move', names);
|
||||||
const msg = formatMsg('move', names);
|
|
||||||
return msg;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getRenameMsg = (from, to) => {
|
const getRenameMsg = (from, to) => {
|
||||||
const msg = formatMsg('rename', {
|
const msg = formatMsg('rename', {
|
||||||
|
|
@ -376,9 +375,8 @@ module.exports._getWin32RootMsg = getWin32RootMsg;
|
||||||
|
|
||||||
function getWin32RootMsg() {
|
function getWin32RootMsg() {
|
||||||
const message = 'Could not copy from/to root on windows!';
|
const message = 'Could not copy from/to root on windows!';
|
||||||
const error = Error(message);
|
|
||||||
|
|
||||||
return error;
|
return Error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseData(data) {
|
function parseData(data) {
|
||||||
|
|
@ -398,12 +396,12 @@ function formatMsg(msg, data, status) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkPut(name, body, callback) {
|
function checkPut(name, body, callback) {
|
||||||
if (typeof name !== 'string')
|
if (!isString(name))
|
||||||
throw Error('name should be a string!');
|
throw Error('name should be a string!');
|
||||||
|
|
||||||
if (typeof body !== 'string')
|
if (!isString(body))
|
||||||
throw Error('body should be a string!');
|
throw Error('body should be a string!');
|
||||||
|
|
||||||
if (typeof callback !== 'function')
|
if (!isFn(callback))
|
||||||
throw Error('callback should be a function!');
|
throw Error('callback should be a function!');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const isString = (a) => typeof a === 'string';
|
||||||
const tryCatch = require('try-catch');
|
const tryCatch = require('try-catch');
|
||||||
|
|
||||||
const exit = require('./exit');
|
const exit = require('./exit');
|
||||||
const columns = require('./columns');
|
const columns = require('./columns');
|
||||||
|
|
||||||
module.exports.root = (dir, config) => {
|
module.exports.root = (dir, config) => {
|
||||||
if (typeof dir !== 'string')
|
if (!isString(dir))
|
||||||
throw Error('dir should be a string');
|
throw Error('dir should be a string');
|
||||||
|
|
||||||
if (dir === '/')
|
if (dir === '/')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue