我试图在gulp文件中将jekyll build
作为节点子进程运行。问题是jekyll build
似乎多次运行而且从未关闭。
我唯一能想到的是jekyll build
进程可能会修改markdown文件,这会导致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.');
});
});
});
答案 0 :(得分:-1)
好吧,似乎问题是我忘了在jekyll node_modules
文件中排除我的_config.yml
目录。必须有这么多的降价文件才能让jekyll不堪重负。
尽管如此,我不确定为什么他们甚至首先触发了gulp.watch
,因为他们没有被编辑。