diff --git a/lib/console/init.js b/lib/console/init.js index e6d66b44..d587029c 100644 --- a/lib/console/init.js +++ b/lib/console/init.js @@ -1,5 +1,6 @@ 'use strict'; +var Promise = require('bluebird'); var pathFn = require('path'); var chalk = require('chalk'); var fs = require('hexo-fs'); @@ -21,6 +22,12 @@ function initConsole(args) { var log = this.log; var promise; + if (fs.existsSync(target) && fs.readdirSync(target).length !== 0) { + log.fatal(chalk.magenta(tildify(target)) + + ' not empty, please run `hexo init` on an empty folder and then copy your files into it'); + return Promise.reject(new Error('target not empty')); + } + log.info('Cloning hexo-starter to', chalk.magenta(tildify(target))); if (args.clone) { diff --git a/lib/context.js b/lib/context.js index 3099c1fa..bd886e70 100644 --- a/lib/context.js +++ b/lib/context.js @@ -6,6 +6,9 @@ var EventEmitter = require('events').EventEmitter; var Promise = require('bluebird'); var ConsoleExtend = require('./extend/console'); +// a stub Hexo object +// see `hexojs/hexo/lib/hexo/index.js` + function Context(base, args) { base = base || process.cwd(); args = args || {}; @@ -53,6 +56,8 @@ Context.prototype.exit = function(err) { chalk.underline('http://hexo.io/docs/troubleshooting.html') ); } + + return Promise.resolve(); }; Context.prototype.unwatch = function() {