From ca722933b20b340fe2466fb764a9e89528dc582a Mon Sep 17 00:00:00 2001 From: Victor Singh Date: Sat, 27 Jan 2018 08:10:31 -0500 Subject: [PATCH] build(package.json): force use yarn (#181) Adds preinstall npm script that will encourage installing dependencies using yarn closes #36 --- package.json | 4 +++- scripts/preinstall-script.js | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 scripts/preinstall-script.js diff --git a/package.json b/package.json index 5b0e2029..10c0bc42 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "packages/*" ], "scripts": { + "preinstall": "scripts/preinstall-script.js", "precommit": "lint-staged", "commit": "git-cz", "test": "jest --coverage", @@ -51,5 +52,6 @@ "standard", "jest --bail --findRelatedTests" ] - } + }, + "dependencies": {} } diff --git a/scripts/preinstall-script.js b/scripts/preinstall-script.js new file mode 100755 index 00000000..a53f1250 --- /dev/null +++ b/scripts/preinstall-script.js @@ -0,0 +1,24 @@ +#!/usr/bin/env node + +const setup = + '\nhttps://github.com/ViacomInc/data-point/blob/master/CONTRIBUTING.md#setup\n' + +if (process.env.npm_execpath.indexOf('yarn') === -1) { + console.error( + '\x1b[41m', + 'Error: You must use yarn to install dependencies.\n\n', + 'For help setting up this project please vist:', + '\x1b[0m', + '\x1b[36m', + '\n', + setup + ) + process.exit(1) +} + +console.warn( + '\x1b[36m%s\x1b[0m', + '\nWe recommend using yarn for this project instead of npm.\n' + + '\nTo learn more about why we use yarn visit:\n' + + setup +)