Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 561 Bytes

038-change-errored-file-in-gulp-on-error.md

File metadata and controls

17 lines (15 loc) · 561 Bytes

Как подменить сломанный .jade/.pug шаблон плейсхолдером

gulp.src('content/*.pug')
  .pipe($.pug({ basedir: '.' }))
  .on('error', function(err) {
    this.push(new File({
      base: 'content/',
      path: err.path.replace(/\.jade/, '.html'),
      contents: Buffer.from('<h1>Fucked Up</h1>'),
    }));
    
    this.emit('end');
  })
  .pipe($.typograf({ lang: 'ru' })) // и типограф, и обработчики ниже получат плейсхолдер
  .pipe(gulp.dest('.build'));