Skip to content

Commit

Permalink
Demo - Support node v17+ (#61)
Browse files Browse the repository at this point in the history
* Support breaking change introduced in Node.js v17

* Update message

* actually set the node variable

* Use node script instead

* add node-version file for most managers

* use a better name
  • Loading branch information
alonso-cadenas authored Feb 8, 2023
1 parent c5c4e19 commit 777ea05
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions demo/.node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.19.0
4 changes: 3 additions & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
"private": true,
"scripts": {
"build": "webpack",
"start": "npm i && webpack-dev-server --open"
"serve": "npm i && webpack-dev-server --open",
"start": "node scripts/start.js npm run serve"
},
"license": "ISC",
"devDependencies": {
"clean-webpack-plugin": "^0.1.19",
"cross-env": "^7.0.3",
"webpack": "^4.23.1",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.10"
Expand Down
24 changes: 24 additions & 0 deletions demo/scripts/start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node

const { spawn } = require('child_process');

const args = process.argv.slice(2);

console.log(`Running on Node.js ${process.version}.`);

const match = /v(\d+)/.exec(process.version);

const needsOpenSslLegacyProvider = match && match[1] > 16;

needsOpenSslLegacyProvider && console.warn('Setting --openssl-legacy-provider to support Node.js v17+.');

const child = spawn('cross-env',
needsOpenSslLegacyProvider ? ['NODE_OPTIONS=--openssl-legacy-provider', ...args] : args, {
shell: true,
stdio: 'inherit'
}
);

child.on('exit', function (code) {
process.exit(code)
})

0 comments on commit 777ea05

Please sign in to comment.