-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 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('hexo-fs'); | ||
const pathFn = require('path'); | ||
|
||
const deleteFolderRecursive = function (path) { | ||
if (fs.existsSync(path)) { | ||
fs.readdirSync(path).forEach(function (file) { | ||
const curPath = path + '/' + file; | ||
if (fs.lstatSync(curPath).isDirectory()) { | ||
deleteFolderRecursive(curPath); | ||
} else { | ||
fs.unlinkSync(curPath); | ||
} | ||
}); | ||
fs.rmdirSync(path); | ||
} | ||
}; | ||
|
||
module.exports = function (args) { | ||
const { log, baseDir, pluginDir, logDir } = this; | ||
const packagePath = pathFn.join(baseDir, 'package.json'); | ||
|
||
// Remove plugin dir | ||
if (fs.existsSync(pluginDir) && fs.lstatSync(pluginDir).isDirectory()) { | ||
deleteFolderRecursive(pluginDir); | ||
} | ||
|
||
// Remove log dir | ||
if (fs.existsSync(logDir) && fs.lstatSync(logDir).isDirectory()) { | ||
deleteFolderRecursive(logDir); | ||
} | ||
|
||
// Rewrite package.json | ||
fs.writeFileSync(packagePath, JSON.stringify({ | ||
'name': 'feflow-home', | ||
'version': '0.0.0', | ||
'private': true | ||
}, null, 4)); | ||
|
||
log.info('Feflow 重新重新初始化完成'); | ||
}; |
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,8 @@ | ||
'use strict'; | ||
|
||
module.exports = function (ctx) { | ||
|
||
const cmd = ctx.cmd; | ||
|
||
cmd.register('clean', 'Clean feflow folder.', {}, require('./clean')); | ||
}; |