yarn-or-npm
Execute scripts with Yarn or npm.
yarn add -D yarn-or-npm# or npm i --save-dev yarn-or-npm
The client is determined by a series of ordered checks:
yarn.lock
file is in the nearest package directory - yarnpackage-lock.json
file is in the nearest package directory - npmyarn
is installed - yarn- Fallback - npm
Module
; // String of `yarn` or `npm` returnedconsole; // Boolean values for hasYarn, hasNpmconsole; // Spawn yarn or npm command; // Spawn sync optionspawn;
Under the covers, there are cached lookup values being used for efficiency. These can be manually cleared:
;; console; // false ; console; // false (cached) yarnOrNpm;console; // true
CLI
yarn-or-npm <command># Can also use `yon` shorthand yon <command>
Package
Modules with bin files can be called directly in package.json
scripts: