Skip to content

Commit 616cd0c

Browse files
committed
inital fablo prune
Signed-off-by: OsamaRab3 <osrab3@gmail.com>
1 parent 4c0bc8d commit 616cd0c

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/commands/prune/index.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
}

0 commit comments

Comments
 (0)