Question

I'm still fairly new to coffeescript. What I would like to do, is be able to force single line comments to be put into the generated javascript. This is so I can load script references with the jasmine test runner built into Resharper.

Required Javascript output:

/// <reference path="/path/to/script.js" />
describe("Some test", function(){
   it("Should do something", function(){
      true.expectToBe(true);
   }
}

Except, I can't seem to get this to happen with coffeescript. Another problem, is that the outputted comment needs to be added to the top of the file, where coffeescript dumps it inside the annonomous function:

(function(){
   /* stuff goes here */
}).call(this)

Is there anyway to do this? I don't mind writing my tests with plain old javascript, but if I can use coffeescript that'd be ideal.

Was it helpful?

Solution

You can turn off the function wrapper with the "bare" flag

coffee --bare x.coffee

and you can output Javascript directly, including comments, by using quotes:

`/// <reference path="/path/to/script.js" />
`
describe 'Some test', -> 
   it 'Should do something', ->
       true.expectToBe(true)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top