Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/console/init.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

var Promise = require('bluebird');
var pathFn = require('path');
var chalk = require('chalk');
var fs = require('hexo-fs');
Expand All @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {};
Expand Down Expand Up @@ -53,6 +56,8 @@ Context.prototype.exit = function(err) {
chalk.underline('http://hexo.io/docs/troubleshooting.html')
);
}

return Promise.resolve();
};

Context.prototype.unwatch = function() {
Expand Down