File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ import { Command } from '@oclif/core' ;
2+ import { spawn } from 'child_process' ;
3+ import * as path from "path" ;
4+
5+
6+ export default class Prune extends Command {
7+ static override description = 'Prune the network and removes all generated files' ;
8+
9+ async run ( ) : Promise < void > {
10+
11+ const shPath = path . resolve ( __dirname , '../../../../fablo.sh' )
12+ const args = [ 'prune' ]
13+
14+ this . log ( `Starting network with: ${ shPath } ${ args . join ( ' ' ) } \n` )
15+ const child = spawn ( shPath , args , {
16+ stdio : [ 'inherit' , 'pipe' , 'pipe' ] ,
17+ shell : process . platform === 'win32' ? 'bash.exe' : true ,
18+ } )
19+
20+ child . stdout ?. on ( 'data' , ( data ) => {
21+ process . stdout . write ( data . toString ( ) )
22+ } )
23+ child . stderr ?. on ( 'data' , ( data ) => {
24+ process . stderr . write ( data . toString ( ) )
25+ } )
26+
27+ child . on ( 'close' , ( code ) => {
28+ if ( code === 0 ) {
29+ this . log ( '\nNetwork Prune successfully!' )
30+ } else {
31+ this . error ( `\nFablo Prune failed with exit code: ${ code } ` )
32+ }
33+ } )
34+
35+ process . on ( 'SIGINT' , ( ) => {
36+ child . kill ( 'SIGINT' )
37+ process . exit ( )
38+ } )
39+ }
40+
41+
42+
43+
44+ }
You can’t perform that action at this time.
0 commit comments