const exec = require('child_process').exec;
function doData(data) {
if (typeof data == 'undefined') {
data = {
command: 'php artisan test:id 1',
time: 3000
};
} else {
data = JSON.parse(data)
}
var timeoutId = setTimeout(
() => {
getData(data.command);
},
data.time
);
if (data.command == 'exit') {
clearTimeout(timeoutId);
}
}
function getData(command) {
console.log(command);
exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
doData(stdout);
});
}
doData();
var timeoutId = setTimeout(
() => {
getData(data.command);
},
data.time
);
if (data.command == 'exit') {
clearTimeout(timeoutId);
}
if (data.command == 'exit') {
return;
}
var timeoutId = setTimeout(
() => {
clearTimeout(timeoutId);
getData(data.command);
},
data.time
);