Skip to content

Commit

Permalink
trying the npm fix
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Feb 9, 2021
1 parent 9021a8c commit 185954d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
"lint:js": "eslint --fix --cache lib test",
"lint:json": "prettier --write codecov.yml .circleci/config.yml .eslintrc",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"posttest": "npm install webpack@^4.44.2",
"posttest": "node set-webpack-version.js \"^4.44.2\" && npm install",
"security": "npm audit --audit-level=moderate",
"test": "npm run test:v4 && npm run test:v5",
"test:v4": "ava",
"test:v5": "npm install webpack@^5.0.0 --no-save && ava"
"test:v5": "node set-webpack-version.js \"^5\" && npm install && ava"
},
"files": [
"lib",
Expand Down
25 changes: 25 additions & 0 deletions set-webpack-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* This file sets Webpack version - both devDependencies and peerDependencies.
*
* This is, for some reason, needed with Windows and maybe npm 6. Running
* "npm install webpack -D" AND manually updating the peerDependencies
* (because npm 6 does not do that but npm 7 does) is not enough. For some
* reason why must, by hand, update the package.json file first and then
* run a normal "npm install".
*/
const fs = require('fs');
const path = require('path');

const version = process.argv[2];
if (!version) {
console.log('Please pass the webpack version - "^4" or "^5" - as an argument.');

process.exit(1);
}

const packageData = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json')));
packageData.peerDependencies.webpack = version;

packageData.devDependencies.webpack = version;

fs.writeFileSync(path.join(__dirname, 'package.json'), JSON.stringify(packageData, null, 2));

0 comments on commit 185954d

Please sign in to comment.