File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 2727* [ Exports as tasks] ( exports-as-tasks.md )
2828* [ Rollup with rollup-stream] ( rollup-with-rollup-stream.md )
2929* [ Run gulp task via cron job] ( cron-task.md )
30+ * [ Running shell commands] ( running-shell-commands.md )
Original file line number Diff line number Diff line change 1+ # Running Shell Commands
2+
3+ Sometimes it is helpful to be able to call existing command line tools from gulp.
4+
5+ There are 2 ways to handle this: node's [ ` child_process ` ] ( https://nodejs.org/api/child_process.html )
6+ built-in module or [ ` gulp-exec ` ] ( https://github.com/robrich/gulp-exec ) if you need to integrate the
7+ command with an existing pipeline.
8+
9+ ``` js
10+ ' use strict' ;
11+
12+ var cp = require (' child_process' );
13+ var gulp = require (' gulp' );
14+
15+ gulp .task (' reset' , function () {
16+ // In gulp 4, you can return a child process to signal task completion
17+ return cp .execFile (' git checkout -- .' );
18+ });
19+ ```
20+
21+ ``` js
22+ ' use strict' ;
23+
24+ var gulp = require (' gulp' );
25+ var exec = require (' gulp-exec' );
26+
27+ gulp .task (' reset' , function () {
28+ return gulp .src (' ./**/**' )
29+ .pipe (exec (' git checkout -- <%= file.path %>' ));
30+ });
31+ ```
You can’t perform that action at this time.
0 commit comments