diff --git a/extensions/linux/index.js b/extensions/linux/index.js index 3b78553f4..d92c0ae8d 100644 --- a/extensions/linux/index.js +++ b/extensions/linux/index.js @@ -41,6 +41,16 @@ class LinuxExtension extends cli.Extension { task: () => this.ui.sudo(`chown -R ghost:ghost ${path.join(ctx.instance.dir, 'content')}`) }], false); } + + uninstall(instance) { + if (os.platform() !== 'linux') { + return Promise.resolve(); + } + + // because we have changed the ownership of the ghost content folder, + // we need to remove it manually here via sudo + return this.ui.sudo(`rm -rf ${path.join(instance.dir, 'content')}`); + } } module.exports = LinuxExtension; diff --git a/lib/commands/uninstall.js b/lib/commands/uninstall.js index 657cb3e1d..8980d6275 100644 --- a/lib/commands/uninstall.js +++ b/lib/commands/uninstall.js @@ -1,5 +1,6 @@ 'use strict'; const fs = require('fs-extra'); +const path = require('path'); const StopCommand = require('./stop'); const Command = require('../command'); @@ -27,23 +28,29 @@ class UninstallCommand extends Command { return Promise.reject(false); } - if (!instance.running) { - return Promise.resolve(); - } - - instance.loadRunningEnvironment(true); - - // If the instance is currently running we need to make - // sure it gets stopped - return this.runCommand(StopCommand); - }).then(() => { - this.system.setEnvironment(!fs.existsSync('config.production.json')); - - return this.ui.run(this.system.hook('uninstall', instance), 'Removing related configuration'); - }).then(() => this.ui.run(() => { - this.system.removeInstance(instance); - return Promise.all(fs.readdirSync('.').map(file => fs.remove(file))); - }, 'Removing Ghost installation')); + return this.ui.listr([{ + title: 'Stopping Ghost', + skip: () => !instance.running, + task: () => { + instance.loadRunningEnvironment(true); + // If the instance is currently running we need to make + // sure it gets stopped + return this.runCommand(StopCommand, {quiet: true}); + } + }, { + title: 'Removing related configuration', + task: () => { + this.system.setEnvironment(!fs.existsSync(path.join(instance.dir, 'config.production.json'))); + return this.system.hook('uninstall', instance); + } + }, { + title: 'Removing Ghost installation', + task: () => { + this.system.removeInstance(instance); + return Promise.all(fs.readdirSync('.').map(file => fs.remove(file))); + } + }]); + }); } }