Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
191
rated 0 times [  195] [ 4]  / answers: 1 / hits: 71091  / 12 Years ago, fri, may 4, 2012, 12:00:00

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.


More From » templates

 Answers
45

I've found a solution so I'd like to share with you.



I'm using grunt under node so, to call terminal commands you need to require 'child_process' module.



For example,



var myTerminal = require(child_process).exec,
commandToBeExecuted = sh myCommand.sh;

myTerminal(commandToBeExecuted, function(error, stdout, stderr) {
if (!error) {
//do something
}
});

[#85785] Thursday, May 3, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tobyl

Total Points: 598
Total Questions: 110
Total Answers: 114

Location: Vietnam
Member since Sat, Feb 12, 2022
2 Years ago
tobyl questions
Tue, Aug 10, 21, 00:00, 3 Years ago
Wed, Jan 13, 21, 00:00, 3 Years ago
Tue, Dec 1, 20, 00:00, 4 Years ago
;