Bash “-s--”标志对npm有什么作用?
我刚刚看了肯特·C·多德的一个节目,他在节目中解释了他的观点 他将以下别名用于Bash “-s--”标志对npm有什么作用?,bash,npm,yarnpkg,flags,npm-scripts,Bash,Npm,Yarnpkg,Flags,Npm Scripts,我刚刚看了肯特·C·多德的一个节目,他在节目中解释了他的观点 他将以下别名用于纱线和npm: ## npm aliases alias ni="npm install"; alias nrs="npm run start -s --"; alias nrb="npm run build -s --"; alias nrd="npm run dev -s --"; alias nrt="npm run test -s --"; alias nrtw="npm run test:watch -s -
纱线
和npm
:
## npm aliases
alias ni="npm install";
alias nrs="npm run start -s --";
alias nrb="npm run build -s --";
alias nrd="npm run dev -s --";
alias nrt="npm run test -s --";
alias nrtw="npm run test:watch -s --";
alias nrv="npm run validate -s --";
alias rmn="rm -rf node_modules";
alias flush-npm="rm -rf node_modules && npm i && say NPM is done";
alias nicache="npm install --prefer-offline";
alias nioff="npm install --offline";
## yarn aliases
alias yar="yarn run";
alias yas="yarn run start -s --";
alias yab="yarn run build -s --";
alias yat="yarn run test -s --";
alias yav="yarn run validate -s --";
alias yoff="yarn add --offline";
alias ypm="echo \"Installing deps without lockfile and ignoring engines\" && yarn install --no-lockfile --ignore-engines"
我想知道,
-s--
标志有什么作用?Kent没有在视频中解释,我在旗帜上找不到任何标志。这意味着命令选项的结束。因此,不能在双破折号后使用命令选项(例如-s
)。但是,例如,您可以通过命令列出要处理的文件
-s
选项本身相当于禁用日志输出的--loglevel=silent
。-s
相当于--silent
--
是表示选项结束的常见Unix约定。在此之后,即使参数看起来像一个选项,它也将被视为一个位置参数。选项-s
使纱线
在标准输出上不输出任何内容,即使其静音
--
来自命令行linux工具,在这些工具中非常常见:
Guideline 10:
The first -- argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character.
因此:
一切正常,它将打印-n
。但是:
> printf -n
bash: printf: -n: invalid option
printf: usage: printf [-v var] format [arguments]
要允许传递-n
,即以前导-
开头的选项作为printf的第一个参数,可以使用--
:
因此:
将按纱线抛出未知选项,因为它将尝试将-p
解析为选项。做:
alias yas="yarn run start -s --";
yas -package
由于没有名为
-package
的包,将通过纱线
抛出未知包。通过使用--
作者有效地阻止了用户(他自己)向Thread传递任何附加选项,因为以下所有参数将仅解释为包名。这是两个标志。按照惯例,-s
是--silent
的缩写--
只是运行的参数的结尾,也是运行任何程序的参数的开始。请参阅(不是安装文档,没有使用安装文档)。可能的重复项还有大写字母S?有区别吗?@ZakherMasri首都S怎么样?比较什么和什么的区别?资本S和小S(-S vs-S)。它是否区分大小写?
> printf -- -n
-n
alias yas="yarn run start -s";
yas -package
alias yas="yarn run start -s --";
yas -package