From c719e37cc1993be73e032028530c74a97638c6eb Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 4 Dec 2020 18:47:24 +0200 Subject: [PATCH] chore(cloudcmd) update dependencies --- .madrun.js | 18 +++++++++--------- common/datetime.spec.js | 9 ++++++--- common/util.spec.js | 11 ++++++++--- test/common/cloudfunc.js | 9 ++++++--- test/server/show-config.js | 11 ++++++++--- 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/.madrun.js b/.madrun.js index 1aa362a3..bcac13a6 100644 --- a/.madrun.js +++ b/.madrun.js @@ -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'), diff --git a/common/datetime.spec.js b/common/datetime.spec.js index da81f65e..3bf1576a 100644 --- a/common/datetime.spec.js +++ b/common/datetime.spec.js @@ -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(); }); diff --git a/common/util.spec.js b/common/util.spec.js index 4875c25c..cb84f18d 100644 --- a/common/util.spec.js +++ b/common/util.spec.js @@ -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(); }); diff --git a/test/common/cloudfunc.js b/test/common/cloudfunc.js index 14ee8f69..99df295c 100644 --- a/test/common/cloudfunc.js +++ b/test/common/cloudfunc.js @@ -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(); }); diff --git a/test/server/show-config.js b/test/server/show-config.js index cb8cd66f..b3b4cf0e 100644 --- a/test/server/show-config.js +++ b/test/server/show-config.js @@ -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(); });