forked from TryGhost/Ghost-CLI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(uninstall): add
ghost uninstall
command
closes TryGhost#187 - adds `ghost uninstall` command that will delete the ghost instance and any related configuration files
- Loading branch information
Showing
5 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
const fs = require('fs-extra'); | ||
|
||
const stop = require('./stop'); | ||
const Config = require('../utils/config'); | ||
const checkValidInstall = require('../utils/check-valid-install'); | ||
|
||
module.exports.execute = function execute() { | ||
checkValidInstall('uninstall'); | ||
|
||
this.ui.log('WARNING: Running this command will delete all of your themes, images, data, and any files related to this ghost instance!\n' + | ||
'There is no going back!', 'yellow'); | ||
|
||
return this.ui.prompt({ | ||
type: 'confirm', | ||
name: 'sure', | ||
message: 'Are you sure you want to do this?', | ||
default: false | ||
}).then((answer) => { | ||
if (!answer.sure) { | ||
return Promise.reject(false); | ||
} | ||
|
||
let config = Config.load('.ghost-cli'); | ||
|
||
if (!config.get('running', false)) { | ||
return Promise.resolve(); | ||
} | ||
|
||
// If the instance is currently running we need to make | ||
// sure it gets stopped | ||
this.environment = config.get('running'); | ||
return stop.execute.apply(this); | ||
}).then(() => { | ||
let config = Config.load(fs.existsSync('config.production.json') ? 'production' : 'development'); | ||
this.service.setConfig(config); | ||
|
||
return this.ui.run(this.service.callHook('uninstall'), 'Removing related configuration'); | ||
}).then(() => this.ui.run(() => { | ||
return Promise.all(fs.readdirSync('.').map(file => fs.remove(file))); | ||
}, 'Removing Ghost installation')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters