Last active
January 16, 2018 23:00
-
-
Save vicapow/28c1c2b10e7a6677470ac07e9a79fa95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
/* global process */ | |
/* eslint-disable no-process-env */ | |
const { execSync } = require('child_process'); | |
const packageJson = require('../../package'); | |
const execpath = process.env && process.env.npm_execpath; | |
if (execpath) { | |
if (!execpath.includes('yarn')) { | |
throw new Error( | |
'You must use Yarn to install, not NPM.' | |
); | |
} | |
} | |
const actual = execSync('yarn --version') | |
.toString() | |
.trim(); | |
const expected = (packageJson.engines || {}).yarn; | |
if (actual !== expected) { | |
throw new Error( | |
` | |
You're running the wrong version of yarn. expected ${expected} but got ${String(actual)}. | |
"brew upgrade yarn" might help. | |
` | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment