更新时间:2022-12-02 18:20:13
虽然我仍然为什么上述方法不工作不清,并欢迎任何反馈,一些研究之后,我发现的shelljs ,我能够用它来解决我的问题。由于shelljs可以Exec的外壳命令同步,我没有与回调在工作的时候我真的希望事情块:
Although I'm still unclear on why the method above is not working, and welcome any feedback, after a bit of research, I found shelljs, which I was able to use to solve my problem. Since shelljs can exec shell commands synchronously, I don't have to work with callbacks when I really want things to block:
module.exports = (grunt) ->
shell = require 'shelljs'
envvar = shell.exec('./bin/get_envvar.sh', {'silent':true}).output
grunt.initConfig
pkg: grunt.file.readJSON('package.json')
env:
dev:
ENV_VAR: envvar
simplemocha:
options:
timeout: 30000
reporter: 'spec'
compilers: 'coffee:coffee-script'
all:
src: ['Tests/**/*.coffee']
grunt.registerTask 'test', ['env', 'simplemocha']
很多清洁呢!
参考文献: