目前我正在努力改进构建网络应用程序的工作流程.
安装了Yeoman后,命令“grunt”为我提供了一个很好的方法来组合和缩小我的javascript文件.
我的main.js文件是从很多coffeescript文件生成的,我之前手动做过.由于文件依赖性,我没有使用编译coffeescript的集成方法. (还行吧)
但问题出在这里:
当我现在尝试运行“grunt”时,它从我生成的js文件中给出了“lint”错误,如:
line 3 col 3 Missing "use strict" statement.
line 3 col 3 Expected 'var' to have an indentation at 5 instead at 3.
line 4 col 102 Expected '{' and instead saw 'child'.
line 4 col 233 A constructor name should start with an uppercase letter.
Warning: Task "jshint:all" failed. Use --force to continue.
如果我 – 强制它继续,outcoming dest文件夹中的main.js仍为空
我能做什么?我认为编译的coffeescript是“lint ready”javascript?
要编译我的coffeescript文件,我使用“rehab”:
https://www.npmjs.org/package/rehab
它为我提供了这个Cakefile:
{exec, spawn} = require 'child_process'
Rehab = require 'rehab'
build = ->
console.log "Building project from src/*.coffee to app/scripts/main.js"
files = new Rehab().process 'src'
files = files.join " "
join_to_single_file = "--join app/scripts/main.js"
compile_from_files = "--compile #{files}"
exec "coffee #{join_to_single_file} #{compile_from_files}", (err, stdout, stderr) ->
throw err if err
task 'build', 'Build coffee2js using Rehab', sbuild = ->
build()
更新:
如果我理解正确,我的main.js文件将永远不会传递jshint,所以我必须从yeoman / grunt删除检查以进一步?我从gruntfile.js中删除了这一行:
// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [
'Gruntfile.js',
// removed '<%= yeoman.app %>/scripts/{,*/}*.js',
'!<%= yeoman.app %>/scripts/vendor/*',
'test/spec/{,*/}*.js'
]
},
现在我没有错误,如果运行“咕噜”,但我在dest文件夹中的输出仍包含一个空的main.js