diff --git a/includes/tasks/check_deps.js b/includes/tasks/check_deps.js new file mode 100644 index 0000000..b68ca5d --- /dev/null +++ b/includes/tasks/check_deps.js @@ -0,0 +1,28 @@ +const logger = require('hexo-log')(); + +function checkDep(name) { + try { + require.resolve(name); + return true; + } catch(e) { + logger.error(`Package ${name} is not installed.`) + } + return false; +} + +logger.info('Checking dependencies'); + +const missingDeps = [ + 'json-stringify-safe', + 'node-prismjs', + 'prismjs', + 'qr-image' +].map(checkDep).some(installed => !installed); + +if (missingDeps) { + logger.error('Please install the missing dependencies.'); + logger.error('You can enter suka-theme directory and run following commands:'); + logger.error('$ npm i --production'); + logger.error('$ yarn --production # If you prefer yarn.'); + process.exit(-1); +} \ No newline at end of file diff --git a/includes/tasks/welcome.js b/includes/tasks/welcome.js new file mode 100644 index 0000000..5bd5b44 --- /dev/null +++ b/includes/tasks/welcome.js @@ -0,0 +1,6 @@ +const logger = require('hexo-log')(); + +logger.info(`---------------------------------- +Suka Theme (https://theme-suka.skk.moe) +---------------------------------------- +`); diff --git a/scripts/index.js b/scripts/index.js new file mode 100644 index 0000000..978c567 --- /dev/null +++ b/scripts/index.js @@ -0,0 +1,9 @@ +// Welcome Message +require('../includes/tasks/welcome'); +// Check required dependencies +require('../includes/tasks/check_deps'); + +// Debug helper +hexo.extend.helper.register('console', function () { + console.log(arguments) +});