-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: dynamic pack version require for the plugin
- Loading branch information
Showing
1 changed file
with
34 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,49 @@ | ||
const chalk = require('chalk'); | ||
const appRoot = require('app-root-path'); | ||
const pack = require(appRoot + '/node_modules/hexo-theme-aurora/package.json'); | ||
const { throwError, throwInfo } = require('./lib/helpers/utils'); | ||
const pluginPack = require('./package.json'); | ||
require('./lib/filters')(hexo); | ||
require('./lib/generators')(hexo); | ||
require('./lib/injector')(hexo); | ||
|
||
var pack; | ||
|
||
try { | ||
pack = require(appRoot + '/node_modules/hexo-theme-aurora/package.json'); | ||
} catch (error) { | ||
throwInfo( | ||
'Aurora Plugin', | ||
`Aurora Plugin fail to get current Aurora Theme version from package location, trying to get from themes folder instead...` | ||
); | ||
try { | ||
pack = require(appRoot + '/themes/hexo-theme-aurora/package.json'); | ||
} catch (error) { | ||
throwError( | ||
'Aurora Plugin Error', | ||
`Aurora Plugin fail to get current Aurora Theme version, please make sure you have the theme installed.` | ||
); | ||
return; | ||
} | ||
} | ||
|
||
hexo.on('generateAfter', function () { | ||
console.log( | ||
chalk.green('INFO ') + | ||
chalk.yellow('API data generated by') + | ||
chalk.cyan.bold(' Aurora v' + pack.version) | ||
chalk.green('INFO ') + | ||
chalk.yellow('API data generated with ') + | ||
chalk.cyan.bold('hexo-plugin-aurora') + | ||
chalk.magenta(' v' + pluginPack.version) | ||
); | ||
}); | ||
|
||
hexo.on('exit', function () { | ||
console.log( | ||
chalk.green('INFO ') + | ||
chalk.magenta('Thanks for using') + | ||
chalk.cyan.bold(' Aurora Plugin v' + pack.version) | ||
); | ||
console.log( | ||
chalk.green('INFO ') + | ||
chalk.magenta('Check out the repo at:') + | ||
chalk.cyan.underline(' https://github.com/auroral-ui/hexo-theme-aurora') | ||
chalk.green('INFO ') + | ||
'Thanks for using: ' + | ||
chalk.cyan.bold('hexo-plugin-aurora') + | ||
chalk.magenta(' v' + pluginPack.version) + | ||
' & ' + | ||
chalk.cyan.bold('hexo-theme-aurora') + | ||
chalk.magenta(' v' + pack.version) | ||
); | ||
console.log(chalk.green('INFO ') + 'Crafted by ' + chalk.cyan.bold('bennyxguo <三钻>')); | ||
}); |