Browse Source

build: add npm version check

Renée Kooi 4 years ago
parent
commit
33e656cad3
2 changed files with 19 additions and 0 deletions
  1. 18 0
      bin/check-npm-version.js
  2. 1 0
      package.json

+ 18 - 0
bin/check-npm-version.js

@@ -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)
+}

+ 1 - 0
package.json

@@ -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",