You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
779 B
38 lines
779 B
'use strict'; |
|
|
|
const Promise = require('bluebird'); |
|
const fs = require('hexo-fs'); |
|
|
|
function cleanConsole(args) { |
|
return Promise.all([ |
|
deleteDatabase(this), |
|
deletePublicDir(this), |
|
this.execFilter('after_clean', null, {context: this}) |
|
]); |
|
} |
|
|
|
function deleteDatabase(ctx) { |
|
const dbPath = ctx.database.options.path; |
|
|
|
return fs.exists(dbPath).then(exist => { |
|
if (!exist) return; |
|
|
|
return fs.unlink(dbPath).then(() => { |
|
ctx.log.info('Deleted database.'); |
|
}); |
|
}); |
|
} |
|
|
|
function deletePublicDir(ctx) { |
|
const publicDir = ctx.public_dir; |
|
|
|
return fs.exists(publicDir).then(exist => { |
|
if (!exist) return; |
|
|
|
return fs.rmdir(publicDir).then(() => { |
|
ctx.log.info('Deleted public folder.'); |
|
}); |
|
}); |
|
} |
|
|
|
module.exports = cleanConsole;
|
|
|