Take the following code snippet.
var exec = require('child_process').exec;
var extraInfo = {'test':1,'passing':'test'};
runWithData(extraInfo);
function runWithData(passedData)
{
exec('/Users/test/Desktop/testcommand', function callback(error,stdout,stderr)
{
if (error)
{
console.log("ERROR",stderr);
}
else
{
console.log(stdout);
}
});
}
Within the callback of exec I want to be able to access the passedData. Is accessing passedData direct the correct way to do this and will this get overwritten if multiple function calls are being processed at the same time, or is there a way to attach the info into the callback function so it is tied to it?