Grunt custom task that alternates between running shell commands and processing JavaScript

77 views Asked by At

I've found this question Grunt Shell output to other task, but what I want to do is a bit more complex.

I'd like to have a custom task that uses grunt-shell commands in a loop. In each loop iteration I then need to also run grunt functions to manipulate files. The pseudo-code would be something like

accept starting and ending git SHAs

loop over them:
check out the next revision (grunt-shell command)
loop over the files from the grunt task's src config (this.filesSrc) and count instances of a particular string (regex), adding the count for each file to a running total

after we've gathered the data from all commits from start to finish, output the results as JSON (grunt.log or write to a file)

I have been able to do the file processing with a custom grunt task, and issuing shell commands with grunt-shell is easy enough to do as a one-time independent task purely via config. What I'd like to do is know how to issue commands once in a while in the middle of a grunt custom task. This git repo forensics is the current example, but I'm sure there are other use cases.

0

There are 0 answers