diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 0000000..3b07263 --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,75 @@ +name: dev +on: + pull_request: + push: + branches: + - master + - main +env: + CI: true + +jobs: + prettier: + name: Format code + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Prettier + uses: gulpjs/prettier_action@v3.0 + with: + commit_message: 'chore: Run prettier' + prettier_options: '--write .' + + test: + name: Tests for Node ${{ matrix.node }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + node: [10, 12, 14, 16] + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: Set Node.js version + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + + - run: node --version + - run: npm --version + + - name: Install npm dependencies + run: npm install + + - name: Run lint + run: npm run lint + + - name: Run tests + run: npm test + + - name: Coveralls + uses: coverallsapp/github-action@v1.1.2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: ${{matrix.os}}-node-${{ matrix.node }} + parallel: true + + coveralls: + needs: test + name: Finish up + + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@v1.1.2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..87cd13c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,16 @@ +name: release +on: + push: + branches: + - master + - main + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: GoogleCloudPlatform/release-please-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + release-type: node + package-name: release-please-action diff --git a/.gitignore b/.gitignore index da8ada8..1ddfd01 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,15 @@ # Logs logs *.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* # Runtime data pids *.pid *.seed +*.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov @@ -13,19 +17,48 @@ lib-cov # Coverage directory used by tools like istanbul coverage +# nyc test coverage +.nyc_output + # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt -# Compiled binary addons (http://nodejs.org/api/addons.html) +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) build/Release -# Dependency directory -# Commenting this out is preferred by some people, see -# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- -node_modules +# Dependency directories +node_modules/ +jspm_packages/ -# Users Environment Variables -.lock-wscript +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# next.js build output +.next # Garbage files .DS_Store diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index 703b33f..0000000 --- a/.jscsrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "preset": "gulp" -} diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..c96ebe0 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +coverage/ +.nyc_output/ +CHANGELOG.md diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0d50ecf..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -sudo: false -language: node_js -node_js: - - '6' - - '5' - - '4' - - '0.12' - - '0.10' -after_script: - - npm run coveralls diff --git a/LICENSE b/LICENSE index 5f5db3d..167c582 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015, 2017 Blaine Bublitz , Eric Schoffstall and other contributors +Copyright (c) 2015, 2017, 2022 Blaine Bublitz and Eric Schoffstall Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md index b75d7d7..f71ed39 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ # async-once -[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url] +[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url] Guarantee a node-style async function is only executed once. @@ -43,18 +43,14 @@ Takes a node-style async function (`fn`) to ensure it's only called once. The fu MIT -[downloads-image]: http://img.shields.io/npm/dm/async-once.svg -[npm-url]: https://npmjs.com/package/async-once -[npm-image]: http://img.shields.io/npm/v/async-once.svg + +[downloads-image]: https://img.shields.io/npm/dm/async-once.svg?style=flat-square +[npm-url]: https://www.npmjs.com/package/async-once +[npm-image]: https://img.shields.io/npm/v/async-once.svg?style=flat-square -[travis-url]: https://travis-ci.org/gulpjs/async-once -[travis-image]: http://img.shields.io/travis/gulpjs/async-once.svg?label=travis-ci - -[appveyor-url]: https://ci.appveyor.com/project/gulpjs/async-once -[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/async-once.svg?label=appveyor +[ci-url]: https://github.com/gulpjs/async-once/actions?query=workflow:dev +[ci-image]: https://img.shields.io/github/workflow/status/gulpjs/async-once/dev?style=flat-square [coveralls-url]: https://coveralls.io/r/gulpjs/async-once -[coveralls-image]: http://img.shields.io/coveralls/gulpjs/async-once/master.svg - -[gitter-url]: https://gitter.im/gulpjs/gulp -[gitter-image]: https://badges.gitter.im/gulpjs/gulp.png +[coveralls-image]: https://img.shields.io/coveralls/gulpjs/async-once/master.svg?style=flat-square + diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 625fc10..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,25 +0,0 @@ -# http://www.appveyor.com/docs/appveyor-yml -# http://www.appveyor.com/docs/lang/nodejs-iojs - -environment: - matrix: - # node.js - - nodejs_version: "0.10" - - nodejs_version: "0.12" - - nodejs_version: "4" - - nodejs_version: "5" - - nodejs_version: "6" - -install: - - ps: Install-Product node $env:nodejs_version - - npm install - -test_script: - - node --version - - npm --version - - cmd: npm test - -build: off - -# build version format -version: "{build}" diff --git a/index.js b/index.js index a2f5ce4..62dd9aa 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ 'use strict'; -var Queue = require('basic-queue'); +var Queue = require('@mapbox/basic-queue'); var wrappy = require('wrappy'); var slice = Array.prototype.slice; @@ -34,7 +34,7 @@ function asyncOnce(fn) { var _queue = new Queue(worker, 1); - return function() { + return function () { var args = slice.call(arguments, 0); var work = { ctx: this, diff --git a/package.json b/package.json index 477f62b..23ee92a 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,14 @@ "name": "async-once", "version": "1.0.1", "description": "Guarantee a node-style async function is only executed once.", - "author": "Gulp Team (http://gulpjs.com/)", + "author": "Gulp Team (https://gulpjs.com/)", "contributors": [ "Blaine Bublitz " ], "repository": "gulpjs/async-once", "license": "MIT", "engines": { - "node": ">= 0.10" + "node": ">=10.13.0" }, "main": "index.js", "files": [ @@ -17,25 +17,30 @@ "index.js" ], "scripts": { - "lint": "eslint index.js test/ && jscs index.js test/", + "lint": "eslint .", "pretest": "npm run lint", - "test": "mocha --async-only", - "cover": "istanbul cover _mocha --report lcovonly", - "coveralls": "npm run cover && istanbul-coveralls" + "test": "nyc mocha --async-only" }, "dependencies": { - "basic-queue": "^1.0.1", - "wrappy": "^1.0.1" + "@mapbox/basic-queue": "^1.0.1", + "wrappy": "^1.0.2" }, "devDependencies": { - "eslint": "^1.10.3", - "eslint-config-gulp": "^2.0.0", - "expect": "^1.20.2", - "istanbul": "^0.4.3", - "istanbul-coveralls": "^1.0.3", - "jscs": "^2.4.0", - "jscs-preset-gulp": "^1.0.0", - "mocha": "^3.5.3" + "eslint": "^7.0.0", + "eslint-config-gulp": "^5.0.0", + "eslint-plugin-node": "^11.1.0", + "expect": "^27.0.0", + "mocha": "^8.0.0", + "nyc": "^15.0.0" + }, + "nyc": { + "reporter": [ + "lcov", + "text-summary" + ] + }, + "prettier": { + "singleQuote": true }, "keywords": [ "once", diff --git a/test/.eslintrc b/test/.eslintrc deleted file mode 100644 index 06b940f..0000000 --- a/test/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "gulp/test" -} diff --git a/test/.gitkeep b/test/.gitkeep new file mode 100644 index 0000000..e69de29