Commit 7699b6f 1 parent 69a9a20 commit 7699b6f Copy full SHA for 7699b6f
File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
2
3
+ if ( process . argv . includes ( "--watchspawn" ) ) {
4
+ require ( "../lib/spawnHook" ) . hook ( ) ;
5
+ }
6
+
3
7
// Execa hook.
4
8
if ( process . argv . includes ( "--execasync" ) ) {
5
9
require ( "../lib/execaHook" ) . hook ( ) ;
Original file line number Diff line number Diff line change
1
+ const childProcess = require ( "child_process" ) ;
2
+ const oldSpawn = childProcess . spawn ;
3
+
4
+ const watchSpawn = ( ...args ) => {
5
+ console . log ( "spawn called" ) ;
6
+ console . log ( ...args ) ;
7
+
8
+ return oldSpawn . apply ( this , ...args ) ;
9
+ } ;
10
+ const hook = ( ) => {
11
+ if ( childProcess . spawn === oldSpawn ) {
12
+ childProcess . spawn = watchSpawn ;
13
+ }
14
+ } ;
15
+
16
+ const unhook = ( ) => {
17
+ if ( childProcess . spawn === watchSpawn ) {
18
+ childProcess . spawn = oldSpawn ;
19
+ }
20
+ } ;
21
+
22
+ module . exports = {
23
+ hook,
24
+ unhook
25
+ } ;
You can’t perform that action at this time.
0 commit comments