From 2a37966413479507664b9a4900767c63c1b31ca4 Mon Sep 17 00:00:00 2001 From: sttk Date: Sun, 7 Nov 2021 15:23:53 +0900 Subject: [PATCH 1/5] chore!: Normalize repository, dropping node <10.13 support --- .github/workflows/dev.yml | 78 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 17 ++++++++ .gitignore | 51 +++++++++++++++++++---- .prettierignore | 3 ++ .travis.yml | 21 ---------- LICENSE | 2 +- README.md | 21 ++++------ appveyor.yml | 26 ------------ lib/is-v8flags.js | 2 +- package.json | 30 ++++++++------ test/.eslintrc | 6 --- test/index.js | 4 +- 12 files changed, 172 insertions(+), 89 deletions(-) create mode 100644 .github/workflows/dev.yml create mode 100644 .github/workflows/release.yml create mode 100644 .prettierignore delete mode 100644 .travis.yml delete mode 100644 appveyor.yml delete mode 100644 test/.eslintrc diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 0000000..442177d --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,78 @@ +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: Run with coverage + run: npm run cover + + - 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..8a10ce3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,17 @@ +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 + bump-minor-pre-major: true diff --git a/.gitignore b/.gitignore index 40e3eff..aa0c563 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,67 @@ # 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 # 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 intermediate storage (https://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 + +# Test results +test.xunit 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 b99514e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -sudo: false - -language: node_js - -node_js: - - '10' - - '8' - - '6' - - '4' - - '0.12' - - '0.10' - -matrix: - fast_finish: true - -script: - if [ $(echo "${TRAVIS_NODE_VERSION}" | cut -d'.' -f1) -ge 4 ]; then - npm run coveralls; - else - npm test; - fi diff --git a/LICENSE b/LICENSE index ca63f90..8853e29 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2018 Tyler Kellen , Blaine Bublitz , and Eric Schoffstall +Copyright (c) 2014-2018, 2021 Tyler Kellen , Blaine Bublitz , Eric Schoffstall and other contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 44899fc..7a4395b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ # flagged-respawn -[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Travis 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] A tool for respawning node binaries when special flags are present. @@ -94,18 +94,15 @@ If `--no-respawning` flag is given in *argv*, this function does not respawned e MIT -[downloads-image]: http://img.shields.io/npm/dm/flagged-respawn.svg -[npm-url]: https://www.npmjs.com/package/flagged-respawn -[npm-image]: http://img.shields.io/npm/v/flagged-respawn.svg -[travis-url]: https://travis-ci.org/gulpjs/flagged-respawn -[travis-image]: http://img.shields.io/travis/gulpjs/flagged-respawn.svg?label=travis-ci + +[downloads-image]: https://img.shields.io/npm/dm/flagged-respawn.svg?style=flat-square +[npm-url]: https://www.npmjs.com/package/flagged-respawn +[npm-image]: https://img.shields.io/npm/v/flagged-respawn.svg?style=flat-square -[appveyor-url]: https://ci.appveyor.com/project/gulpjs/flagged-respawn -[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/flagged-respawn.svg?label=appveyor +[ci-url]: https://github.com/gulpjs/flagged-respawn/actions?query=workflow:dev +[ci-image]: https://img.shields.io/github/workflow/status/gulpjs/flagged-respawn/dev?style=flat-square [coveralls-url]: https://coveralls.io/r/gulpjs/flagged-respawn -[coveralls-image]: http://img.shields.io/coveralls/gulpjs/flagged-respawn/master.svg - -[gitter-url]: https://gitter.im/gulpjs/gulp -[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg +[coveralls-image]: https://img.shields.io/coveralls/gulpjs/flagged-respawn/master.svg?style=flat-square + diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index bd65027..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,26 +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: "6" - - nodejs_version: "8" - - nodejs_version: "10" - -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/lib/is-v8flags.js b/lib/is-v8flags.js index 34df9d2..5362a19 100644 --- a/lib/is-v8flags.js +++ b/lib/is-v8flags.js @@ -7,7 +7,7 @@ function replaceSeparatorsFromDashesToUnderscores(flag) { if (!arr) { return flag; } - return arr[1] + arr[2].replace(/\-/g, '_'); + return arr[1] + arr[2].replace(/-/g, '_'); } module.exports = isV8flags; diff --git a/package.json b/package.json index 1d38d81..6d1f81c 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "repository": "gulpjs/flagged-respawn", "license": "MIT", "engines": { - "node": ">= 0.10" + "node": ">= 10.13.0" }, "main": "index.js", "files": [ @@ -24,21 +24,27 @@ "lint": "eslint .", "pretest": "npm run lint", "test": "mocha --async-only", - "cover": "nyc --reporter=lcov --reporter=text-summary npm test", - "coveralls": "npm run cover && istanbul-coveralls", + "cover": "nyc mocha --async-only", "respawn": "node test/bin/respawner --harmony test", "nospawn": "node test/bin/respawner test" }, - "dependencies": {}, "devDependencies": { - "eslint": "^2.13.0", - "eslint-config-gulp": "^3.0.1", - "expect": "^1.20.2", - "istanbul": "^0.4.3", - "istanbul-coveralls": "^1.0.3", - "mocha": "^3.5.3", - "nyc": "^11.3.0", - "v8flags": "^3.0.1" + "eslint": "^7.32.0", + "eslint-config-gulp": "^5.0.1", + "eslint-plugin-node": "^11.1.0", + "expect": "^27.3.1", + "mocha": "^8.4.0", + "nyc": "^15.1.0", + "v8flags": "^3.2.0" + }, + "nyc": { + "reporter": [ + "lcov", + "text-summary" + ] + }, + "prettier": { + "singleQuote": true }, "keywords": [ "respawn", diff --git a/test/.eslintrc b/test/.eslintrc deleted file mode 100644 index c8cdccd..0000000 --- a/test/.eslintrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "gulp/test", - "rules": { - "no-console": 0 - } -} diff --git a/test/index.js b/test/index.js index 4f08b37..729668a 100644 --- a/test/index.js +++ b/test/index.js @@ -121,7 +121,7 @@ describe('flaggedRespawn', function() { it('should respawn; if child is killed, parent should exit with same signal', function(done) { // Because travis and nyc hates this - if (process.env.TRAVIS || process.env.NYC_PARENT_PID) { + if (process.env.TRAVIS || process.env.NYC_PARENT_PID || process.env.NYC_PROCESS_ID) { this.skip(); return; } @@ -174,7 +174,7 @@ describe('flaggedRespawn', function() { expect(results.length).toEqual(2); var params = JSON.parse(results[0]); - expect(params.child_pid).toNotEqual(params.process_pid); + expect(params.child_pid).not.toEqual(params.process_pid); params = JSON.parse(results[1]); expect(params.child_pid).toEqual(params.process_pid); From 4c9d6a4a0229b21c651902fe3c3d3120d29edde6 Mon Sep 17 00:00:00 2001 From: Takayuki Sato Date: Mon, 8 Nov 2021 19:44:40 +0900 Subject: [PATCH 2/5] Update LICENSE Co-authored-by: Blaine Bublitz --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 8853e29..924a628 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2018, 2021 Tyler Kellen , Blaine Bublitz , Eric Schoffstall and other contributors +Copyright (c) 2014-2018, 2021 Tyler Kellen , 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 From 4d17f951f8bdd0a3e761bd7fea1665685dc88db4 Mon Sep 17 00:00:00 2001 From: Takayuki Sato Date: Mon, 8 Nov 2021 19:45:17 +0900 Subject: [PATCH 3/5] Update test/index.js Co-authored-by: Blaine Bublitz --- test/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/index.js b/test/index.js index 729668a..c20748b 100644 --- a/test/index.js +++ b/test/index.js @@ -121,7 +121,7 @@ describe('flaggedRespawn', function() { it('should respawn; if child is killed, parent should exit with same signal', function(done) { // Because travis and nyc hates this - if (process.env.TRAVIS || process.env.NYC_PARENT_PID || process.env.NYC_PROCESS_ID) { + if (process.env.NYC_PARENT_PID || process.env.NYC_PROCESS_ID) { this.skip(); return; } From abf4a28814afd092139d7248bdae5100ee868635 Mon Sep 17 00:00:00 2001 From: sttk Date: Mon, 8 Nov 2021 20:20:31 +0900 Subject: [PATCH 4/5] fix: modified what pointed out in review --- .github/workflows/dev.yml | 3 --- package.json | 7 ++----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 442177d..3b07263 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -55,9 +55,6 @@ jobs: - name: Run tests run: npm test - - name: Run with coverage - run: npm run cover - - name: Coveralls uses: coverallsapp/github-action@v1.1.2 with: diff --git a/package.json b/package.json index 6d1f81c..67fb2e8 100644 --- a/package.json +++ b/package.json @@ -23,10 +23,7 @@ "scripts": { "lint": "eslint .", "pretest": "npm run lint", - "test": "mocha --async-only", - "cover": "nyc mocha --async-only", - "respawn": "node test/bin/respawner --harmony test", - "nospawn": "node test/bin/respawner test" + "test": "nyc mocha --async-only" }, "devDependencies": { "eslint": "^7.32.0", @@ -35,7 +32,7 @@ "expect": "^27.3.1", "mocha": "^8.4.0", "nyc": "^15.1.0", - "v8flags": "^3.2.0" + "v8flags": "^4.0.0" }, "nyc": { "reporter": [ From a518e945c97366ce79a314786b71e5d6640df979 Mon Sep 17 00:00:00 2001 From: sttk Date: Wed, 17 Nov 2021 12:16:42 +0900 Subject: [PATCH 5/5] Fix: Drop support of flags separated by underscores. --- lib/is-v8flags.js | 10 +--------- test/index.js | 19 +++---------------- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/lib/is-v8flags.js b/lib/is-v8flags.js index 5362a19..c43a470 100644 --- a/lib/is-v8flags.js +++ b/lib/is-v8flags.js @@ -1,13 +1,5 @@ function isV8flags(flag, v8flags) { - return v8flags.indexOf(replaceSeparatorsFromDashesToUnderscores(flag)) >= 0; -} - -function replaceSeparatorsFromDashesToUnderscores(flag) { - var arr = /^(-+)(.*)$/.exec(flag); - if (!arr) { - return flag; - } - return arr[1] + arr[2].replace(/-/g, '_'); + return v8flags.indexOf(flag) >= 0; } module.exports = isV8flags; diff --git a/test/index.js b/test/index.js index c20748b..414e061 100644 --- a/test/index.js +++ b/test/index.js @@ -9,17 +9,11 @@ var remover = require('../lib/remover'); var flaggedRespawn = require('../'); describe('flaggedRespawn', function() { - var flags = ['--harmony', '--use_strict', '--stack_size']; + var flags = ['--harmony', '--use-strict', '--stack-size']; describe('isV8flags', function() { it('should return true when flag is in v8flags', function(done) { expect(isV8flags('--harmony', flags)).toEqual(true); - expect(isV8flags('--use_strict', flags)).toEqual(true); - expect(isV8flags('--stack_size', flags)).toEqual(true); - done(); - }); - - it('should ignore separator differences of "-" and "_"', function(done) { expect(isV8flags('--use-strict', flags)).toEqual(true); expect(isV8flags('--stack-size', flags)).toEqual(true); done(); @@ -43,13 +37,6 @@ describe('flaggedRespawn', function() { }); it('should keep flags values when not placed first', function(done) { - var args = ['node', 'file.js', '--stack_size=2048']; - var expected = ['node', '--stack_size=2048', 'file.js']; - expect(reorder(flags, args)).toEqual(expected); - done(); - }); - - it('should re-order args when flag separators are dashes', function(done) { var args = ['node', 'file.js', '--stack-size=2048']; var expected = ['node', '--stack-size=2048', 'file.js']; expect(reorder(flags, args)).toEqual(expected); @@ -79,7 +66,7 @@ describe('flaggedRespawn', function() { }); it('should remove a arg even when the arg has value', function(done) { - var args = ['node', 'file.js', '--stack_size=2048']; + var args = ['node', 'file.js', '--stack-size=2048']; var expected = ['node', 'file.js']; expect(remover(flags, args)).toEqual(expected); done(); @@ -278,7 +265,7 @@ describe('flaggedRespawn', function() { '1234', '--cwd', 'bbb/ccc/ddd', - '--prof_browser_mode', + '--prof-browser-mode', '-V', ].join(' ');