Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a command in a Grunt Task

I'm using Grunt (task-based command line build tool for JavaScript projects) in my project. I've created a custom tag and I am wondering if it is possible to run a command into it.

To clarify, I'm trying to use Closure Templates and "the task" should call the jar file to pre-compile the Soy file to a javascript file.

I'm running this jar from command line, but I want to set it as a task.

like image 855
JuanO Avatar asked May 04 '12 22:05

JuanO


People also ask

What does Grunt command do?

Grunt is a JavaScript task runner, a tool used to automatically perform frequent tasks such as minification, compilation, unit testing, and linting. It uses a command-line interface to run custom tasks defined in a file (known as a Gruntfile). Grunt was created by Ben Alman and is written in Node.

How do you check if a task exists in Grunt?

grunt.task.existsCheck with the name, if a task exists in the registered tasks.


1 Answers

Alternatively you could load in grunt plugins to help this:

grunt-shell example:

shell: {   make_directory: {     command: 'mkdir test'   } } 

or grunt-exec example:

exec: {   remove_logs: {     command: 'rm -f *.log'   },   list_files: {     command: 'ls -l **',     stdout: true   },   echo_grunt_version: {     command: function(grunt) { return 'echo ' + grunt.version; },     stdout: true   } } 
like image 156
papercowboy Avatar answered Sep 23 '22 08:09

papercowboy