gruntjs/grunt-contrib — pull request #35 by illicium (2012-06-12 08:03:14+00:00)
Title: coffee: Fix options object being mangled after multiple compiles causing bad output

When compiling CoffeeScript, if multiple files are specified in grunt.js,

coffee: {
compile: {
options: {
header: true
},
files: {
'a.js': 'a.coffee',
'b.js': 'b.coffee'
}
}
}

The compiler populates the options object with its own properties, which is then reused for later compilations. For the above files, the `opts` objects being passed to the compiler look something like this:

{ filename: 'a.coffee' }

{ filename: 'b.coffee',
indent: ' ',
scope:
{ parent: null,
expressions: { expressions: [Object], spaced: true, tab: ' ' },
method: null,
variables: [ [Object], [Object] ],
positions: { A: 1 } },
level: 1 }

The first file compiles fine, but because of the leftover `scope` property, later files don't get closures and internal functions like `__extends` as they should.