From 5802eca7f9b02e0cda601ee2effa5197c014a957 Mon Sep 17 00:00:00 2001 From: Vahan Minasian Date: Mon, 11 Feb 2019 17:33:59 +0100 Subject: [PATCH] feat(enforce-yarn): enforce yarn instead of npm on install of packages --- package.json | 1 + scripts/enforce-yarn.js | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 scripts/enforce-yarn.js diff --git a/package.json b/package.json index 1ec4016..efdabdf 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.0.0", "description": "seed repository with basic functionality", "scripts": { + "preinstall": "node scripts/enforce-yarn.js", "commit": "git-cz", "enforce:gitflow": "node ./node_modules/.bin/enforce-gitflow-branches" }, diff --git a/scripts/enforce-yarn.js b/scripts/enforce-yarn.js new file mode 100644 index 0000000..1c279da --- /dev/null +++ b/scripts/enforce-yarn.js @@ -0,0 +1,8 @@ +/** + * Restrict using `npm` for installing packages + */ +if (process.env.npm_execpath.indexOf('yarn') === -1) { + console.error('You must use Yarn to install dependencies:'); + console.error(' $ yarn install'); + process.exit(1); +}