2015-02-06 60 views
-1

我试图运行jekyll build作为gulp文件中的节点子进程。问题是,jekyll build似乎正在运行多次,并从未关闭。作为节点子进程运行时Jekyll构建不关闭

我能想到的唯一可能是jekyll build进程修改降价文件,这将导致gulp.watch再次运行。我没有看到这方面的任何证据。

如果我只是从终端运行jekyll build我得到这个:

Configuration file: /home/user_name/projects/project_name/_config.yml 
      Source: /home/user_name/projects/project_name 
     Destination: /home/user_name/projects/project_name/_site 
     Generating... 
        done. 
Auto-regeneration: disabled. Use --watch to enable. 

当我运行它作为一个子节点过程中,我得到这个:

[20:59:03] Configuration file: /home/user_name/projects/project_name/_config.yml 
      Source: /home/user_name/projects/project_name 
     Destination: /home/user_name/projects/project_name/_site 
     Generating... 

[20:59:03] Configuration file: /home/user_name/projects/project_name/_config.yml 
      Source: /home/user_name/projects/project_name 
     Destination: /home/user_name/projects/project_name/_site 
     Generating... 

[20:59:03] Configuration file: /home/user_name/projects/project_name/_config.yml 
      Source: /home/user_name/projects/project_name 
     Destination: /home/user_name/projects/project_name/_site 
     Generating... 

它不断重复这样的20+然后停止并在此之后不输出任何内容。

这里是我的gulpfile.js:

var gulp = require('gulp'); 
var spawn = require('child_process').spawn; 
var gutil = require('gulp-util'); 

gulp.task('default', function() { 
    gulp.watch('**/*.md', function (e) { 
    var cp  = spawn('jekyll', ['build']), 
     stdout = '', 
     stderr = ''; 

    cp.stdout.setEncoding('utf8'); 

    cp.stdout.on('data', function (data) { 
     stdout += data; 
     gutil.log(data); 
    }); 

    cp.stderr.setEncoding('utf8'); 

    cp.stderr.on('data', function (data) { 
     stderr += data; 
     gutil.log(gutil.colors.red(data)); 
    }); 

    cp.on('error', function (err) { 
     gutil.log(gutil.colors.red('gulp-jekyll', err)); 
    }); 

    cp.on('close', function (code) { 
     gutil.log('Done with exit code ', code); 
     gutil.log('Jekyll has completed the build process.'); 
    }); 

    }); 
}); 

回答

-1

好吧,看来问题是我忘了排除在哲基尔_config.yml文件我node_modules目录。肯定有这么多markdown文件,它不堪重负jekyll。

不过,我不知道为什么他们甚至首先触发了gulp.watch,因为他们没有被编辑。