Running a shell command from gulp

后端 未结 4 1163
小蘑菇
小蘑菇 2020-12-12 18:03

I would like to run a shell command from gulp, using gulp-shell. I see the following idiom being used the gulpfile.

Is this the idiomatic way to run a c

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 18:52

    You could simply do this:

    const { spawn } = require('child_process');
    const gulp = require('gulp');
    
    gulp.task('list', function() {
        const cmd = spawn('ls');
        cmd.stdout.on('data', (data) => {
            console.log(`stdout: ${data}`);
        });
        return cmd;
    });
    

提交回复
热议问题