Sending response after file changes

I want to execute a commande in *matlab* using *shelljs* and after it finish send response to client :

 var cmd = 'matlab -nojvm -nosplash -nodesktop -noFigureWindows  -minimize -r  \"  senario(); exit; \"';
     shell.exec(cmd, function (code, stdout, stderr) {
            console.log('matlab exit');

I didn't know how to get the response so I made matlab change a file with Code (Ok, Fail) and watched it using *fswatch*, my aim was after a change send the 200 status, but it is throwing an error while testing with Postman."done.json", function (event, filename) {
    console.log(filename + ' file Changed ...');
        return res.status(200); // I want to Add the response here
    if (filename) {
        console.log('filename provided: ' + filename);
    } else {
        console.log('filename not provided');

I know that seems not the good way to do so, but any help

Relevant tags