|
1 | 1 | 'use strict';
|
2 | 2 | const fs = require('fs-extra');
|
| 3 | +const path = require('path'); |
3 | 4 |
|
4 | 5 | const StopCommand = require('./stop');
|
5 | 6 | const Command = require('../command');
|
@@ -27,23 +28,29 @@ class UninstallCommand extends Command {
|
27 | 28 | return Promise.reject(false);
|
28 | 29 | }
|
29 | 30 |
|
30 |
| - if (!instance.running) { |
31 |
| - return Promise.resolve(); |
32 |
| - } |
33 |
| - |
34 |
| - instance.loadRunningEnvironment(true); |
35 |
| - |
36 |
| - // If the instance is currently running we need to make |
37 |
| - // sure it gets stopped |
38 |
| - return this.runCommand(StopCommand); |
39 |
| - }).then(() => { |
40 |
| - this.system.setEnvironment(!fs.existsSync('config.production.json')); |
41 |
| - |
42 |
| - return this.ui.run(this.system.hook('uninstall', instance), 'Removing related configuration'); |
43 |
| - }).then(() => this.ui.run(() => { |
44 |
| - this.system.removeInstance(instance); |
45 |
| - return Promise.all(fs.readdirSync('.').map(file => fs.remove(file))); |
46 |
| - }, 'Removing Ghost installation')); |
| 31 | + return this.ui.listr([{ |
| 32 | + title: 'Stopping Ghost', |
| 33 | + skip: () => !instance.running, |
| 34 | + task: () => { |
| 35 | + instance.loadRunningEnvironment(true); |
| 36 | + // If the instance is currently running we need to make |
| 37 | + // sure it gets stopped |
| 38 | + return this.runCommand(StopCommand, {quiet: true}); |
| 39 | + } |
| 40 | + }, { |
| 41 | + title: 'Removing related configuration', |
| 42 | + task: () => { |
| 43 | + this.system.setEnvironment(!fs.existsSync(path.join(instance.dir, 'config.production.json'))); |
| 44 | + return this.system.hook('uninstall', instance); |
| 45 | + } |
| 46 | + }, { |
| 47 | + title: 'Removing Ghost installation', |
| 48 | + task: () => { |
| 49 | + this.system.removeInstance(instance); |
| 50 | + return Promise.all(fs.readdirSync('.').map(file => fs.remove(file))); |
| 51 | + } |
| 52 | + }]); |
| 53 | + }); |
47 | 54 | }
|
48 | 55 | }
|
49 | 56 |
|
|
0 commit comments