JSFiddle - React, Tailwind, and code Playground
JavaScript
function Executor(program, args, errorAction) {
this.program = program;
this.args = args;
this.successAction = function(data) {
console.log(data);
};
this.errorAction = function(err) {
console.log(err);
};
this.execute = function() {
var argsString = "";
for(var o in args) {
argsString += args[o] + ' ';
}
var command = this.program + ' ' + argsString;
console.log("Execution => " + command);
this.errorAction("йоба"); // тут выполняется
exec(command, function(err, data) {
if(err != null) {
this.errorAction(err); // а тут нет :(
} else {
this.successAction(data);
}
});
}
this.execute();
}