mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
remove hashbang before parsing JS file (#499)
This commit is contained in:
parent
7415bda02b
commit
3ce43c2f32
@ -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, '/**')
|
||||
|
||||
|
||||
@ -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() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user