Skip to content

Commit

Permalink
feat!: drop support for EOL Node 8 (#1686)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Jul 6, 2020
1 parent 028b50d commit 863937f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
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`)
}
}

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

0 comments on commit 863937f

Please sign in to comment.