benjamn / benjamn/recast

Files with shebang support?

Open
#376 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.3k
Forks
363
Avg merge
3d 8h
Merged PRs (30d)
3

Description

Recast fail to parse files with a shebang impeaching its use on node bin files:
```
#! /usr/bin/env node

console.log('hello');
```

I will probably use a regExp to match and strip it in the meanwhile but i think it would be nice to have it in the core.

FYI I found the same kind of issues while trying to find one in this project: https://github.com/es-analysis/plato/issues/66

FYI till:
```
function _stripShebang(content) {
if(/#! (\/\w+)+ node/.test(content)) {
log('debug', 'Found a shebang, commenting it', path);
content = '// Shebang commented by xxxx: ' + content;
}
return content;
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the failure with the shebang-containing Node example from the issue and compare it with the same file without the shebang. Done means Recast parses the example without requiring the caller-side stripping workaround described in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.