chore(cloudcmd) update dependencies

This commit is contained in:
coderaiser 2020-12-04 18:47:24 +02:00
parent 4c7f8cc6b6
commit c719e37cc1
5 changed files with 37 additions and 21 deletions

View file

@ -29,7 +29,7 @@ module.exports = {
return `${cmd} ${names}`;
},
'test': () => `${env} ${run('test:base')}`,
'test': async () => `${env} ${await run('test:base')}`,
'test:client': () => `tape 'test/client/**/*.js'`,
'test:server': () => `tape 'test/**/*.js' 'server/**/*.spec.js' 'common/**/*.spec.js'`,
'wisdom': () => run(['lint:all', 'build', 'test']),
@ -116,23 +116,23 @@ module.exports = {
'docker:rm:latest-arm32': () => dockerRmi('arm32'),
'docker:rm:arm64': () => dockerRmi('arm64', version),
'docker:rm:latest-arm64': () => dockerRmi('arm64'),
'docker:rm-old': () => `${parallel('docker:rm:*')} || true`,
'docker:rm-old': async () => `${await parallel('docker:rm:*')} || true`,
'coverage': () => `${env} nyc ${run('test:base')}`,
'coverage': async () => `${env} nyc ${await run('test:base')}`,
'report': () => 'nyc report --reporter=text-lcov | coveralls',
'6to5': () => 'webpack --progress',
'6to5:client': () => run('6to5', '--mode production'),
'6to5:client:dev': () => `NODE_ENV=development ${run('6to5', '--mode development')}`,
'6to5:client:dev': async () => `NODE_ENV=development ${await run('6to5', '--mode development')}`,
'pre6to5:client': () => 'rimraf dist',
'pre6to5:client:dev': () => 'rimraf dist-dev',
'watch:client': () => run('6to5:client', '--watch'),
'watch:client:dev': () => run('6to5:client:dev', '--watch'),
'watch:server': () => 'nodemon bin/cloudcmd.js',
'watch:lint': () => `nodemon -w client -w server -w webpack.config.js -x ${run('lint')}`,
'watch:test': () => `nodemon -w client -w server -w test -w common -x ${run('test')}`,
'watch:test:client': () => `nodemon -w client -w test/client -x ${run('test:client')}`,
'watch:test:server': () => `nodemon -w client -w test/client -x ${run('test:server')}`,
'watch:coverage': () => `nodemon -w server -w test -w common -x ${run('coverage')}`,
'watch:lint': async () => `nodemon -w client -w server -w webpack.config.js -x ${await run('lint')}`,
'watch:test': async () => `nodemon -w client -w server -w test -w common -x ${await run('test')}`,
'watch:test:client': async () => `nodemon -w client -w test/client -x ${await run('test:client')}`,
'watch:test:server': async () => `nodemon -w client -w test/client -x ${await run('test:server')}`,
'watch:coverage': async () => `nodemon -w server -w test -w common -x ${await run('coverage')}`,
'build': () => run('6to5:*'),
'build:client': () => run('6to5:client'),
'build:client:dev': () => run('6to5:client:dev'),

View file

@ -1,6 +1,8 @@
'use strict';
const test = require('supertape');
const tryCatch = require('try-catch');
const datetime = require('./datetime');
test('common: datetime', (t) => {
@ -9,7 +11,7 @@ test('common: datetime', (t) => {
const expected = '2018.08.17 10:56:48';
t.equals(result, expected, 'should equal');
t.equal(result, expected, 'should equal');
t.end();
});
@ -39,14 +41,15 @@ test('common: 0 before number', (t) => {
const expected = '2018.08.17 10:56:08';
t.equals(result, expected, 'should equal');
t.equal(result, expected, 'should equal');
t.end();
});
test('common: datetime: wrong args', (t) => {
const fn = () => datetime({});
const [error] = tryCatch(datetime, {});
t.throws(fn, /date should be instanceof Date!/, 'should throw');
t.equal(error.message, 'date should be instanceof Date!', 'should throw');
t.end();
});

View file

@ -2,7 +2,9 @@
const test = require('supertape');
const {reRequire} = require('mock-require');
const tryCatch = require('try-catch');
const Util = require('./util');
const {
findObjByNameInArr,
getRegExp,
@ -35,13 +37,16 @@ test('util: getExt: no name', (t) => {
});
test('util: findObjByNameInArr: no array', (t) => {
t.throws(findObjByNameInArr, /array should be array!/, 'should throw when no array');
const [error] = tryCatch(findObjByNameInArr);
t.equal(error.message, 'array should be array!', 'should throw when no array');
t.end();
});
test('util: findObjByNameInArr: no name', (t) => {
const fn = () => findObjByNameInArr([]);
t.throws(fn, /name should be string!/, 'should throw when no name');
const [error] = tryCatch(findObjByNameInArr, []);
t.equal(error.message, 'name should be string!', 'should throw when no array');
t.end();
});

View file

@ -1,6 +1,7 @@
'use strict';
const fs = require('fs');
const tryCatch = require('try-catch');
const DIR = __dirname + '/../../';
const COMMONDIR = DIR + 'common/';
@ -181,16 +182,18 @@ test('cloudfunc: getHeaderField', (t) => {
});
test('cloudfunc: getPathLink: no url', (t) => {
t.throws(CloudFunc.getPathLink, 'should throw when no url');
const [error] = tryCatch(CloudFunc.getPathLink);
t.ok(error, 'should throw when no url');
t.end();
});
test('cloudfunc: getPathLink: no template', (t) => {
const url = 'http://abc.com';
const prefix = '';
const fn = () => CloudFunc.getPathLink(url, prefix);
const [error] = tryCatch(CloudFunc.getPathLink, url, prefix);
t.throws(fn, 'should throw when no template');
t.ok(error, 'should throw when no template');
t.end();
});

View file

@ -1,16 +1,21 @@
'use strict';
const test = require('supertape');
const tryCatch = require('try-catch');
const showConfig = require('../../server/show-config');
test('cloudcmd: show-config: no arguments', (t) => {
t.throws(showConfig, /config could not be empty!/, 'should throw when no config');
const [error] = tryCatch(showConfig);
t.equal(error.message, 'config could not be empty!', 'should throw when no config');
t.end();
});
test('cloudcmd: show-config: bad arguments', (t) => {
const fn = () => showConfig('hello');
t.throws(fn, /config should be an object!/, 'should throw when config not object');
const [error] = tryCatch(showConfig, 'hello');
t.equal(error.message, 'config should be an object!', 'should throw when config not object');
t.end();
});