1

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.

Dmitry Osinovskiy
  • 9,999
  • 1
  • 47
  • 38
Mitchell Lee
  • 456
  • 3
  • 14

1 Answers1

2

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)
Thilo
  • 257,207
  • 101
  • 511
  • 656
  • 1
    Awesome, exactly what I was looking for. Just as a note, if your using mindscape web workbench plugin for Visual Studio, you can turn the --bare option on for specific files (your test scripts) under the workbench settings. Thanks for the quick answer! – Mitchell Lee Jun 15 '13 at 15:28
  • And if you use Web Essentials, you can do the same things with Tools->Options->Web Essentials->CoffeeScript->Wrap generated Javascript Files->False – perlyking Nov 27 '14 at 21:23