index.html
(フルパスはCONFIG.APP.INDEX
)の変更を監視するとエラーが発生します。すべての私の仕事は別々のファイルにあります。これは例えば、タスク/ watch.tsです:最初の変更タスクのGulp 4 - エラー:書き込み終了後
import * as CONFIG from '../config';
export default done => {
// other watches
gulp.watch(CONFIG.APP.INDEX, gulp.series('inject'));
};
正常に実行されますが、2番目の変更に私はこのエラーを取得しています:
c:\~\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:203
var er = new Error('write after end');
^
Error: write after end
at writeAfterEnd (c:\~\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:203:12)
at DestroyableTransform.Writable.write (c:\~\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:239:20)
at DestroyableTransform.ondata (c:\~\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:531:20)
at emitOne (events.js:77:13)
at DestroyableTransform.emit (events.js:169:7)
at readableAddChunk (c:\~\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:198:18)
at DestroyableTransform.Readable.push (c:\~\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:157:10)
at DestroyableTransform.Transform.push (c:\~\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:123:32)
at afterTransform (c:\~\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:79:51)
at TransformState.afterTransform (c:\~\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:58:12)
at c:\~\node_modules\vinyl-fs\lib\src\getContents\bufferFile.js:18:5
at c:\~\node_modules\graceful-fs\graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:404:3)
タスク/注入.TSタスク:
declare var require;
const gulp = require('gulp');
const plugins = require('gulp-load-plugins')();
import * as CONFIG from '../config';
export default done => {
return gulp
.src(CONFIG.APP.INDEX)
.pipe(require('../util/inject/fixes').default) // <--- PROBLEM IS HERE
// other stuff...
.pipe(gulp.dest(CONFIG.DST.BUILD))
.on('error', plugins.util.log);
};
のutil /注入/ fixes.tsタスク
declare var require;
const plugins = require('gulp-load-plugins')();
// errors even with this...
export default plugins.util.noop();
タスクは、このようなgulpfile.ts/index.ts
からロードされています
fs.readdirSync('./gulpfile.ts/tasks').map(file => {
let name = file.replace(/\.ts$/, '');
let task = require(path.join(path.resolve('.'), 'gulpfile.ts', 'tasks', file));
gulp.task(name, task.default);
});
私はエラーがどこから来るのかを識別するために管理していないが、それを引き起こしているものは考え、またはそれを修正する方法をしました。最初に変更してタスクを実行した後にindex.html
を見ているときにのみ発生する問題は、です。実行中のタスクは手動で正常に動作し(gulp inject
)、他のすべての時計とタスクは正常に動作します。