-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.js
26 lines (19 loc) · 721 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var fs = require("fs");
var path = require("path");
function useYarn(optionsOrMessage) {
const options =
// Backwards compatibility since we used to accept only an optional message string
typeof optionsOrMessage === "string"
? { message: optionsOrMessage }
: optionsOrMessage;
const npm_execpath = options.npm_execpath || process.env.npm_execpath;
const isNpmNotYarn = Boolean(npm_execpath) && !/\byarn\b/.test(npm_execpath);
if (isNpmNotYarn && process.env.DISABLE_USE_YARN !== "true") {
const message =
options.message ||
fs.readFileSync(path.resolve(__dirname, "message.txt"), "utf8");
console.error(message);
process.exit(1);
}
}
module.exports = useYarn;