我有以下gulpfile.js
var gulp = require('gulp'), browserSync = require('browser-sync'), sass = require('gulp-sass'), bower = require('gulp-bower'), notify = require('gulp-notify'), reload = browserSync.reload, bs = require("browser-sync").create(), Hexo = require('hexo'), hexo = new Hexo(process.cwd(), {}); var src = { scss: './scss/', css: './source/css', ejs: 'layout' }, watchFiles = [ './scss/*.scss', '*/*.ejs' ]; // Static Server + watching scss/html files gulp.task('serve', ['sass:watch'], function() { // init starts the server bs.init(watchFiles, { server: { baseDir: "../../public" }, logLevel: "debug" }); hexo.init(); hexo.call('generate', {}, function(){ console.log('Started Hexo Server'); }) });
如何在gulpfile中的watch中启动hexo?
gulpfile的其余部分在这里:
https://github.com/chrisjlee/hexo-theme-zurb-foundation/blob/master/gulpfile.js
hexo索引文件在这里接受参数;但我无法弄清楚这些论点;
https://github.com/hexojs/hexo/blob/master/lib/hexo/index.js
答案 0 :(得分:2)
您可以在第二个参数中传递参数。例如:
hexo.init().then(function(){
return hexo.call('generate', {watch: true});
}).catch(function(err){
console.log(err);
});