Skip to content

Instantly share code, notes, and snippets.

@vicapow
Last active January 16, 2018 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vicapow/28c1c2b10e7a6677470ac07e9a79fa95 to your computer and use it in GitHub Desktop.
Save vicapow/28c1c2b10e7a6677470ac07e9a79fa95 to your computer and use it in GitHub Desktop.
// @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