gulp-exec icon indicating copy to clipboard operation
gulp-exec copied to clipboard

Powershell logs during the execution

Open VGBenjamin opened this issue 3 years ago • 1 comments

Hello,

How could I have the logs of my powershell tasks during the execution? Because for the moment, I am only able to write the result of my execution when the powershell execution is finished and that is an issue for the long running tasks because we have the feeling that nothing happen.

Here is the function I currently use:

const child_process = require('child_process');
const exec = child_process.exec;
function executePS(scriptPath, callback) {
    exec("Powershell.exe  -executionpolicy remotesigned " + scriptPath, function (err, stdout, stderr) {
        console.log(stdout);
        console.log(stderr);
        callback(err);
    });
}

exports.executePS = executePS;

Regards,

VGBenjamin avatar Mar 05 '21 09:03 VGBenjamin

It looks like you've graduated from gulp-exec, and should consume child_process directly. exec only returns the stream at the end, but spawn will stream the output as you go. Check out https://stackoverflow.com/questions/48698234/node-js-spawn-vs-execute and https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options

robrich avatar Mar 05 '21 18:03 robrich