0
votes

I have the following 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');
    })

});

How does one start hexo in a watch in a gulpfile?

The rest of the gulpfile is here:

https://github.com/chrisjlee/hexo-theme-zurb-foundation/blob/master/gulpfile.js

The hexo index file takes in arguments here; but i couldn't figure out the arguments;

https://github.com/hexojs/hexo/blob/master/lib/hexo/index.js

1

1 Answers

2
votes

You can pass arguments in the second parameter. For example:

hexo.init().then(function(){
  return hexo.call('generate', {watch: true});
}).catch(function(err){
  console.log(err);
});