Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for files with a node shebang #19

Closed
sevko opened this issue Jan 26, 2015 · 5 comments
Closed

add support for files with a node shebang #19

sevko opened this issue Jan 26, 2015 · 5 comments

Comments

@sevko
Copy link

sevko commented Jan 26, 2015

depcheck doesn't appear to take into account files without a .js extension but that contain a node shebang (eg #!/usr/bin/env node). Example:

$ tree -L 1
.
├── executable
├── node_modules
└── package.json

1 directory, 2 files

$ cat package.json
{
    "dependencies": {
        "through": "latest"
    }
}

$ cat executable
#!/usr/bin/env node
var through = require("through");

$ depcheck
Unused Dependencies
* through

Renaming executable to executable.js resolves the problem, though.

@rumpl
Copy link
Member

rumpl commented Jan 26, 2015

Hello,

Yes, depcheck only checks for js files. I'm not sure that detective can parse files with the shebang in them, if he can than that's great!

It would be great if there was a command line parameter for forcing additional files that are not .js.

Something like: depcheck --additionnal=bin/main,bin/other. What do you think about that ?

@sevko
Copy link
Author

sevko commented Jan 26, 2015

Since shebangs are only ever present at the beginning of a file, you can check the first line containing non-whitespace characters against a regular expression like ^[ \t]*#!.*node (jshint somehow implements this). A flag could be a useful additional feature.

@dominicbarnes
Copy link

+1

@lijunle
Copy link
Member

lijunle commented Jul 21, 2015

The acorn parse support allowHashBang options naturally.

dylang pushed a commit to dylang/depcheck that referenced this issue Oct 14, 2015
@lijunle
Copy link
Member

lijunle commented Nov 4, 2015

I think version 0.5.9 has supported this now. Could anybody help to test it?

I will add a test case to cover this later.


UPDATE:

The current version (0.5.9) has supported this. However, I have added a test case to assert the support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants