| 300 | } |
| 301 | |
| 302 | async function removeDockerVolumes(volumes: string[]): Promise<boolean> { |
| 303 | if (volumes.length === 0) { |
| 304 | return true; |
| 305 | } |
| 306 | return new Promise<boolean>((resolve) => { |
| 307 | const child = spawn('docker', ['volume', 'rm', ...volumes], { stdio: ['ignore', 'ignore', 'pipe'] }); |
| 308 | let err = ''; |
| 309 | child.stderr?.on('data', (chunk: Buffer) => { |
| 310 | err += chunk.toString(); |
| 311 | }); |
| 312 | child.on('exit', (code) => { |
| 313 | if (code !== 0 && err.trim()) { |
| 314 | console.error(chalk.red('✗ ') + err.trim()); |
| 315 | } |
| 316 | resolve(code === 0); |
| 317 | }); |
| 318 | child.on('error', () => resolve(false)); |
| 319 | }); |
| 320 | } |
| 321 | |
| 322 | type ComposeContainer = { Name: string; Service: string; State: string }; |
| 323 | |