mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore(cloudcmd) lint
This commit is contained in:
parent
8f466b4c9a
commit
111eba8c31
33 changed files with 139 additions and 155 deletions
|
|
@ -2,13 +2,11 @@
|
|||
|
||||
const success = (f) => (data) => f(null, data);
|
||||
|
||||
module.exports = (promise) => {
|
||||
return (...a) => {
|
||||
const fn = a.pop();
|
||||
|
||||
promise(...a)
|
||||
.then(success(fn))
|
||||
.catch(fn);
|
||||
};
|
||||
module.exports = (promise) => (...a) => {
|
||||
const fn = a.pop();
|
||||
|
||||
promise(...a)
|
||||
.then(success(fn))
|
||||
.catch(fn);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,31 +1,32 @@
|
|||
'use strict';
|
||||
|
||||
const test = require('supertape');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
|
||||
const {
|
||||
test,
|
||||
stub,
|
||||
} = require('supertape');
|
||||
const callbackify = require('./callbackify');
|
||||
const {promisify} = require('util');
|
||||
|
||||
test('cloudcmd: common: callbackify: error', (t) => {
|
||||
const promise = async () => {
|
||||
throw Error('hello');
|
||||
};
|
||||
test('cloudcmd: common: callbackify: error', async (t) => {
|
||||
const promise = stub().rejects(Error('hello'));
|
||||
|
||||
const fn = callbackify(promise);
|
||||
const [error] = await tryToCatch(promisify(fn));
|
||||
|
||||
fn((e) => {
|
||||
t.equal(e.message, 'hello');
|
||||
t.end();
|
||||
});
|
||||
t.equal(error.message, 'hello');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: common: callbackify', (t) => {
|
||||
const promise = async () => {
|
||||
return 'hi';
|
||||
};
|
||||
test('cloudcmd: common: callbackify', async (t) => {
|
||||
const promise = stub().resolves('hi');
|
||||
|
||||
const fn = callbackify(promise);
|
||||
const promiseAgain = promisify(fn);
|
||||
const data = await promiseAgain();
|
||||
|
||||
fn((e, data) => {
|
||||
t.equal(data, 'hi');
|
||||
t.end();
|
||||
});
|
||||
t.equal(data, 'hi');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ test('cloudfunc: getSize: dir', (t) => {
|
|||
|
||||
const expected = '<dir>';
|
||||
|
||||
t.equal(result, expected, 'should equal');
|
||||
t.equal(result, expected);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ test('cloudfunc: getSize: link: dir', (t) => {
|
|||
|
||||
const expected = '<link>';
|
||||
|
||||
t.equal(result, expected, 'should equal');
|
||||
t.equal(result, expected);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ test('cloudfunc: getSize: link: file', (t) => {
|
|||
|
||||
const expected = '<link>';
|
||||
|
||||
t.equal(result, expected, 'should equal');
|
||||
t.equal(result, expected);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -134,6 +134,6 @@ test('cloudfunc: getSize: file', (t) => {
|
|||
|
||||
const expected = '100.00kb';
|
||||
|
||||
t.equal(result, expected, 'should equal');
|
||||
t.equal(result, expected);
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ test('common: datetime', (t) => {
|
|||
|
||||
const expected = '2018.08.17 10:56:48';
|
||||
|
||||
t.equal(result, expected, 'should equal');
|
||||
t.equal(result, expected);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ test('common: 0 before number', (t) => {
|
|||
|
||||
const expected = '2018.08.17 10:56:08';
|
||||
|
||||
t.equal(result, expected, 'should equal');
|
||||
t.equal(result, expected);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -113,12 +113,12 @@ test('util: getRegExp: no', (t) => {
|
|||
});
|
||||
|
||||
test('util: escapeRegExp: no str', (t) => {
|
||||
t.equal(escapeRegExp(1), 1, 'should equal');
|
||||
t.equal(escapeRegExp(1), 1);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('util: escapeRegExp', (t) => {
|
||||
t.equal(escapeRegExp('#hello'), '\\#hello', 'should equal');
|
||||
t.equal(escapeRegExp('#hello'), '\\#hello');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue