build: add npm version check

This commit is contained in:
Renée Kooi 2021-02-15 09:22:21 +01:00
parent 4cfff53b6c
commit 33e656cad3
No known key found for this signature in database
GPG key ID: 9940E33D1A44ADBF
2 changed files with 19 additions and 0 deletions

18
bin/check-npm-version.js Normal file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env node
'use strict'
const userAgent = process.env.npm_config_user_agent
if (!userAgent) {
// not much we can do
process.exit()
}
if (/^npm\/7/.test(userAgent)) {
console.error('Please use npm 6 to work in the Uppy monorepo.')
console.error('You can execute individual commands with npm 6 like below:')
console.error()
console.error(' $ npx npm@6 install')
console.error()
console.error('This way you can still use npm 7 in your other projects.')
process.exit(1)
}

View file

@ -240,6 +240,7 @@
"lint:markdown": "remark -f -q . -i .gitignore",
"lint:staged": "lint-staged",
"lint": "eslint . --cache",
"preinstall": "node ./bin/check-npm-version.js",
"release": "bash ./bin/release",
"size": "echo 'JS Bundle mingz:' && cat ./packages/uppy/dist/uppy.min.js | gzip | wc -c && echo 'CSS Bundle mingz:' && cat ./packages/uppy/dist/uppy.min.css | gzip | wc -c",
"start:companion": "bash ./bin/companion",