以下shell脚本应检查我的ruby项目是否有lint coffeescript和scss。
#!/usr/bin/env ruby
puts "\n== Checking if CoffeeScript is lint =="
checks << system("coffeelint -f .coffeelint.json ./app/assets/javascripts/**/*.coffee")
puts "\n== Checking if SCSS is lint =="
checks << system("scss-lint ./app/assets/stylesheets/**/*.scss")
exit 1 if checks.include?(false)
但是 zsh 中运行该脚本的输出如下:
== Checking if CoffeeScript is lint ==
fs.js:849
return binding.stat(pathModule._makeLong(path));
^
Error: ENOENT: no such file or directory, stat './app/assets/javascripts/**/*.coffee'
at Error (native)
at Object.fs.statSync (fs.js:849:18)
at findCoffeeScripts (/Users/josua/.nvm/versions/io.js/v2.3.3/lib/node_modules/coffeelint/lib/commandline.js:79:14)
at Object.<anonymous> (/Users/josua/.nvm/versions/io.js/v2.3.3/lib/node_modules/coffeelint/lib/commandline.js:247:17)
at Object.<anonymous> (/Users/josua/.nvm/versions/io.js/v2.3.3/lib/node_modules/coffeelint/lib/commandline.js:254:4)
at Module._compile (module.js:430:26)
at Object.Module._extensions..js (module.js:448:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/josua/.nvm/versions/io.js/v2.3.3/lib/node_modules/coffeelint/bin/coffeelint:34:5)
at Module._compile (module.js:430:26)
at Object.Module._extensions..js (module.js:448:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:471:10)
at startup (node.js:117:18)
at node.js:948:3
== Checking if SCSS is lint ==
No such file or directory @ rb_sysopen - ./app/assets/stylesheets/**/*.scss
似乎当前的工作路径是错误的,但至少puts system("pwd")
显示正确的目录,参数中的相对路径应该从该目录到达。
这里发生了什么?