diff --git a/.editorconfig b/.editorconfig index 0253534..f607091 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,7 +3,7 @@ root = true [*] charset = utf-8 indent_style = tab -indent_size = 4 +indent_size = 2 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true diff --git a/.eslintrc.js b/.eslintrc.js index 0fe1720..b3424df 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,6 +8,7 @@ module.exports = { sourceType: 'module' }, env: { + mocha: true, es6: true, browser: true, node: true, @@ -38,9 +39,9 @@ module.exports = { 'no-console': 0, // 不在 else 中 return 'no-else-return': 0, - // 用什么来缩进,规定使用tab 来进行缩进,switch中case也需要一个tab . - 'indent': [2, 'tab', { 'SwitchCase': 1 }], - // 对于回调类型函数,不必坚持 return + // 用什么来缩进,规定使用tab 来进行缩进,switch中case也需要一个tab . + 'indent': [2, 'tab', { 'SwitchCase': 1 }], + // 对于回调类型函数,不必坚持 return 'consistent-return': 0, // 不推荐解构赋值 'prefer-destructuring': 0, diff --git a/.travis.yml b/.travis.yml index 2a8bd10..7f74758 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: - - 8 + - 12 cache: yarn: true diff --git a/gulpfile.js b/gulpfile.js index 0188349..cd7c0a5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,7 +2,6 @@ const $fs = require('fs'); const $path = require('path'); const $gulp = require('gulp'); const $gulpMocha = require('gulp-mocha'); -const $runSequence = require('run-sequence'); const $upload = require('./index'); const $config = require('./test/config'); @@ -50,14 +49,13 @@ $gulp.task( .pipe($gulpMocha()) ); -$gulp.task('test', () => $runSequence( +$gulp.task('test', $gulp.series( 'prepare', 'upload', 'upload-withBase', 'mocha' )); -$gulp.task('default', [ +$gulp.task('default', $gulp.series( 'test' -]); - +)); diff --git a/index.js b/index.js index 6e51320..b8d7350 100644 --- a/index.js +++ b/index.js @@ -23,12 +23,14 @@ const requestParam = { const upload = options => { options = options || {}; - let conf = Object.assign({ + let conf = { prefix: '', debug: false, log: true, - overwrite: false - }, requestParam, options); + overwrite: false, + ...requestParam, + ...options + }; let nTotal = 0; let nSkip = 0; @@ -74,7 +76,7 @@ const upload = options => { nTotal++; - let spec = Object.assign({}, conf); + let spec = { ...conf }; spec.FilePath = file.path; spec.Key = uploadPath; @@ -111,4 +113,3 @@ const upload = options => { }; module.exports = upload; - diff --git a/package.json b/package.json index 03273a8..1f7d88d 100644 --- a/package.json +++ b/package.json @@ -34,36 +34,31 @@ }, "homepage": "https://github.com/TabSpace/gulp-qcloud-cos-upload#readme", "devDependencies": { - "@commitlint/cli": "^7.5.2", - "@commitlint/config-conventional": "^7.5.0", - "babel-eslint": "8.0.2", - "chai": "4.1.2", - "commitizen": "^3.0.5", - "cz-conventional-changelog": "^2.1.0", - "eslint": "4.10.0", - "eslint-config-airbnb-base": "12.1.0", - "eslint-friendly-formatter": "3.0.0", - "eslint-plugin-import": "2.8.0", - "gulp": "3.9.1", - "gulp-mocha": "4.3.1", - "husky": "^1.3.1", - "lint-staged": "^8.1.4", - "mocha": "4.0.1", - "request-promise": "4.2.2", - "run-sequence": "2.2.0", - "semantic-release": "^15.13.3" + "@commitlint/cli": "^9.1.1", + "@commitlint/config-conventional": "^9.1.1", + "babel-eslint": "^10.1.0", + "commitizen": "^4.1.2", + "cz-conventional-changelog": "^3.2.0", + "eslint": "^7.5.0", + "eslint-config-airbnb-base": "^14.2.0", + "eslint-friendly-formatter": "^4.0.1", + "eslint-plugin-import": "^2.22.0", + "gulp": "^4.0.2", + "gulp-mocha": "^7.0.2", + "husky": "^4.2.5", + "lint-staged": "^10.2.11", + "mocha": "^8.0.1", + "power-assert": "^1.6.1", + "request-promise": "^4.2.6", + "semantic-release": "^17.1.1" }, "dependencies": { "chalk": "^2.4.2", "fancy-log": "^1.3.3", "plugin-error": "^1.0.1", - "qcloud-cos-upload": "^1.2.8", - "through2": "2.0.3", - "url-join": "2.0.2" - }, - "engines": { - "node": ">= 8.0.0", - "npm": ">= 5.0.0" + "qcloud-cos-upload": "^1.3.1", + "through2": "^4.0.2", + "url-join": "^4.0.1" }, "husky": { "hooks": { diff --git a/test/test.js b/test/test.js index 46c8e08..f32f90a 100644 --- a/test/test.js +++ b/test/test.js @@ -1,16 +1,9 @@ const $fs = require('fs'); const $path = require('path'); const $rp = require('request-promise'); -const $chai = require('chai'); -const $mocha = require('mocha'); +const $assert = require('power-assert'); const $config = require('./config'); -const { - describe, - it, - before -} = $mocha; - const domain = `${$config.Bucket}-${$config.AppId}.coscd.myqcloud.com`; const perfix = $config.prefix; const base = 'base'; @@ -43,13 +36,13 @@ describe('check-upload', function () { }); it('File 1 exists', () => { - $chai.expect(test1cosRs).to.be.a('string'); - $chai.expect(test1cosRs).to.include(tsContent); + $assert(typeof test1cosRs === 'string'); + $assert(test1cosRs.indexOf(tsContent) >= 0); }); it('File 2 exists', () => { - $chai.expect(test2cosRs).to.be.a('string'); - $chai.expect(test2cosRs).to.include(tsContent); + $assert(typeof test2cosRs === 'string'); + $assert(test2cosRs.indexOf(tsContent) >= 0); }); }); @@ -71,7 +64,7 @@ describe('check-uploadBase', function () { }); it('File 1 exists', () => { - $chai.expect(test1cosRs).to.be.a('string'); - $chai.expect(test1cosRs).to.include(tsContent); + $assert(typeof test1cosRs === 'string'); + $assert(test1cosRs.indexOf(tsContent) >= 0); }); });