anoop anoop - 9 months ago 51
Git Question

JSHint not accepting file content as argument

I am trying to make a server side git

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
tool. But the issue with the
tool is that it is not accepting the file content as the argument.

Is there any way by which I can make the
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.

Answer Source

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