Skip to content

Commit

Permalink
Merge pull request #6 from auroral-ui/beta
Browse files Browse the repository at this point in the history
fix: package version reading path for themes folder
  • Loading branch information
bennyxguo authored Aug 4, 2023
2 parents 9dadfef + 91d510e commit f5d2b45
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
const chalk = require('chalk');
const appRoot = require('app-root-path');
const { throwError, throwInfo } = require('./lib/helpers/utils');
const chalk = require('chalk');
const pluginPack = require('./package.json');
const { throwInfo, throwError } = require('./lib/helpers/utils');
require('./lib/filters')(hexo);
require('./lib/generators')(hexo);
require('./lib/injector')(hexo);

var pack;
var themePack;

try {
pack = require(appRoot + '/node_modules/hexo-theme-aurora/package.json');
themePack = 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');
themePack = require(appRoot + '/themes/aurora/package.json');
} catch (error) {
throwError(
'Aurora Plugin Error',
Expand All @@ -43,7 +43,7 @@ hexo.on('exit', function () {
chalk.magenta(' v' + pluginPack.version) +
' & ' +
chalk.cyan.bold('hexo-theme-aurora') +
chalk.magenta(' v' + pack.version)
chalk.magenta(' v' + themePack.version)
);
console.log(chalk.green('INFO ') + 'Crafted by ' + chalk.cyan.bold('bennyxguo <三钻>'));
});
13 changes: 7 additions & 6 deletions lib/generators/site.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
const appRoot = require('app-root-path');
const { throwInfo, throwError } = require('../helpers/utils');
var pack;

var themePack;

try {
pack = require(appRoot + '/node_modules/hexo-theme-aurora/package.json');
themePack = require(appRoot + '/node_modules/hexo-theme-aurora/package.json');
} catch (error) {
throwInfo(
'Aurora Site Generator',
'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');
themePack = require(appRoot + '/themes/aurora/package.json');
} catch (error) {
throwError(
'Aurora Site Generator Error',
'Aurora Plugin Error',
`Aurora Plugin fail to get current Aurora Theme version, please make sure you have the theme installed.`
);
return;
Expand All @@ -24,7 +25,7 @@ class SiteGenerator {
data = {};

constructor(configs) {
configs.theme_config.version = pack.version;
configs.theme_config.version = themePack.version;
this.data = configs;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ exports.throwError = function (type, msg) {
console.error(
`${chalk.red('[ERROR]')} ${chalk.yellow(
`Please create an issue @ https://github.com/auroral-ui/hexo-plugin-aurora/issues with the above error message. Thanks!
请在 @ https://github.com/auroral-ui/hexo-plugin-aurora/issues 提交一个 issue, 并附带以上报错信息, 谢谢!`
请在 @https://github.com/auroral-ui/hexo-plugin-aurora/issues 提交一个 issue, 并附带以上报错信息, 谢谢!`
)}`
);
};
Expand Down

0 comments on commit f5d2b45

Please sign in to comment.