( !'which npm' )
在以下代码中是什么意思?
if ( !'which npm' ) {
die(
'You need to install NPM!' . PHP_EOL
);
}
以下是GITHUB完整文件的链接:WPBP/generator/bin/wpbp-generator
答案 0 :(得分:14)
它检查硬编码的字符串是否为 falsey 。永远是false
。
这种逻辑看起来有点没有意义。我怀疑作者宁愿写:
if (!`which npm`)
backtick operator将命令作为shell命令执行,这更有意义。