anoop
anoop

Reputation: 539

JSHint not accepting file content as argument

I am trying to make a server side git pre-receive hook for checking the code quality of php and javascript files. So the repo server will make the git push fail, if the pre-receive hook fails the test. Since the server doesn't have the physical file with the content from the latest commit, I have tried getting the file contents and piping them to the php linting tools. It was successful.

For javascript file, I am using the jshint tool. But the issue with the jshint tool is that it is not accepting the file content as the argument.

Is there any way by which I can make the jshint accept file content instead of the file name ? One solution I find is by writing a temporary file. But that is not an ideal solution.

Upvotes: 0

Views: 42

Answers (1)

Andrey
Andrey

Reputation: 4050

Jshint could also read contents from the STDIN if you specify - instead of filename. So you can forward your file contents to stdin and you won't need temporary file.

$ jshint -
var a = 2

stdin: line 1, col 10, Missing semicolon.

1 error

Upvotes: 1

Related Questions