mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Preinstall check that mentions 'yarn kbn' (#16572)
This commit is contained in:
parent
3448f31e3d
commit
88c18d667f
2 changed files with 33 additions and 0 deletions
|
@ -41,6 +41,7 @@
|
|||
"Yuri Astrakhan <yuri@elastic.co>"
|
||||
],
|
||||
"scripts": {
|
||||
"preinstall": "node ./preinstall_check",
|
||||
"kbn": "node scripts/kbn",
|
||||
"test": "grunt test",
|
||||
"test:dev": "grunt test:dev",
|
||||
|
|
32
preinstall_check.js
Normal file
32
preinstall_check.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
const isUsingNpm = process.env.npm_config_git !== undefined;
|
||||
|
||||
if (isUsingNpm) {
|
||||
throw "Use Yarn instead of npm, see Kibana's contributing guidelines";
|
||||
}
|
||||
|
||||
// The value of the `npm_config_argv` env for each command:
|
||||
//
|
||||
// - `npm install`: '{"remain":[],"cooked":["install"],"original":[]}'
|
||||
// - `yarn`: '{"remain":[],"cooked":["install"],"original":[]}'
|
||||
// - `yarn kbn bootstrap`: '{"remain":[],"cooked":["run","kbn"],"original":["kbn","bootstrap"]}'
|
||||
const rawArgv = process.env.npm_config_argv;
|
||||
|
||||
if (rawArgv === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const argv = JSON.parse(rawArgv);
|
||||
|
||||
if (argv.cooked.includes('kbn')) {
|
||||
// all good, trying to install deps using `kbn`
|
||||
return;
|
||||
}
|
||||
|
||||
if (argv.cooked.includes('install')) {
|
||||
console.log('\nWARNING: When installing dependencies, prefer `yarn kbn bootstrap`\n');
|
||||
}
|
||||
} catch (e) {
|
||||
// if it fails we do nothing, as this is just intended to be a helpful message
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue