(!'哪个npm')在PHP脚本中是什么意思?

时间:2018-08-30 10:28:46

标签: php npm which

( !'which npm' )在以下代码中是什么意思?

if ( !'which npm' ) {
  die(
        'You need to install NPM!' . PHP_EOL
  );
}

以下是GITHUB完整文件的链接:WPBP/generator/bin/wpbp-generator

1 个答案:

答案 0 :(得分:14)

它检查硬编码的字符串是否为 falsey 。永远是false

这种逻辑看起来有点没有意义。我怀疑作者宁愿写:

if (!`which npm`)

backtick operator将命令作为shell命令执行,这更有意义。