remove hashbang before parsing JS file (#499)

This commit is contained in:
Jeff Williams 2013-09-30 22:24:50 -07:00
parent 7415bda02b
commit 3ce43c2f32
2 changed files with 13 additions and 0 deletions

View File

@ -144,6 +144,9 @@ exports.Parser.prototype.getVisitors = function() {
function pretreat(code) {
return code
// comment out hashbang at the top of the file, like: #!/usr/bin/env node
.replace(/^(\#\![\S \t]+\n)/, '// $1')
// make starbangstar comments look like real jsdoc comments
.replace(/\/\*\!\*/g, '/**')

View File

@ -113,6 +113,16 @@ describe("jsdoc/src/parser", function() {
expect(parse).not.toThrow();
});
it("should comment out a POSIX hashbang at the start of the file", function() {
function parse() {
parser.parse(parserSrc);
}
var parserSrc = 'javascript:#!/usr/bin/env node\n/** class */function Foo() {}';
expect(parse).not.toThrow();
});
});
describe("results", function() {