Can Yarn list all available scripts?
https://github.com/yarnpkg/yarn/issues/2965
Use
yarn run
, just like npmnpm run
npm run
is too slow, I got response for almost 5 seconds sometimes.
I've been using cat package.json
for years, but I had to scroll the screen in terminal every time because package.json
is too long (more than one screen).
So I filter it via grep
and sed
.grep
print 50 lines after match scripts
, and sed
used to match the other parentheses, then quit without continue print.
$ grep "scripts" -A 50 ./package.json | sed '/}/ q' # run it on package.json directory
So I append it to ~/.bashrc
via alias scripts="grep 'scripts' -A 20 ./package.json | sed '/}/ q'"
.
And next time, I just run scripts
, then I got all scripts content on package.json
.
Cool~
Another solution is with jq.
jq .scripts package.json
Output example:
{
"dev": "webpack-dev-server --mode development",
"build": "webpack --mode production"
}
You could add the script to your list of scripts and use yarn scripts
"scripts": {
"scripts": "jq .scripts package.json"
}