Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: drop support for EOL Node 8 #1686

Merged
merged 3 commits into from Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/release-please.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [8, 10, 12, 13]
node: [10, 12, 13, 14]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
Expand Down
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -125,6 +125,12 @@ Having problems? want to contribute? join our [community slack](http://devtoolsc
* [Customizing Yargs' Parser](/docs/advanced.md#customizing)
* [Contributing](/contributing.md)

## Supported Node.js Versions

Libraries in this ecosystem make a best effort to track
[Node.js' release schedule](https://nodejs.org/en/about/releases/). Here's [a
post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).

[travis-url]: https://travis-ci.org/yargs/yargs
[travis-image]: https://img.shields.io/travis/yargs/yargs/master.svg
[npm-url]: https://www.npmjs.com/package/yargs
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -86,6 +86,6 @@
],
"license": "MIT",
"engines": {
"node": ">=8"
"node": ">=10"
}
}
9 changes: 9 additions & 0 deletions test/yargs.js
Expand Up @@ -2583,4 +2583,13 @@ describe('yargs dsl tests', () => {
argv._.should.eql(['item2', 'item4', 'item6', 'item8'])
})
})

it('throws error for unsupported Node.js versions', () => {
process.env.YARGS_MIN_NODE_VERSION = '55'
delete require.cache[require.resolve('../yargs')]
expect(() => {
require('../yargs')
}).to.throw(/yargs supports a minimum Node.js version of 55/)
delete process.env.YARGS_MIN_NODE_VERSION
})
})
13 changes: 10 additions & 3 deletions yargs.js
@@ -1,8 +1,15 @@
'use strict'

// an async function fails early in Node.js versions prior to 8.
async function requiresNode8OrGreater () {}
requiresNode8OrGreater()
// See https://github.com/yargs/yargs#supported-nodejs-versions for our
// version support policy. The YARGS_MIN_NODE_VERSION is used for testing only.
const minNodeVersion = (process && process.env && process.env.YARGS_MIN_NODE_VERSION)
? Number(process.env.YARGS_MIN_NODE_VERSION) : 10
if (process && process.version) {
const major = Number(process.version.match(/v([^.]+)/)[1])
if (major < minNodeVersion) {
throw Error(`yargs supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs#supported-nodejs-versions`)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've started throwing on unsupported versions of Node.js, otherwise folks can get bit somewhere down the road, e.g., when we pull in a feature like async generators, which aren't supported in Node 8.

}
}

const { Yargs, rebase } = require('./build/lib/yargs')
const Parser = require('yargs-parser')
Expand Down