Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gulp.task('templates', () => {
return gulp
.src(`${PATHS.source.templates.pages}/**/*.pug`)
.pipe(plumber(getPluginOptions('plumber')))
.pipe(getData(() => glob
.sync(`${PATHS.source.data}/**/*.json`)
.map(parseDataFile)
.concat({ books, tags })
.reduce(mergeObjects, {})))
.pipe(pug(getPluginOptions('pug')))
.pipe(rename((path) => {
if (path.basename !== 'index') {
path.dirname = path.basename; // eslint-disable-line no-param-reassign
path.basename = 'index'; // eslint-disable-line no-param-reassign
}
}))
.pipe(gulp.dest(PATHS.build.templates));
});
gulp.task('compile-pug', () => {
return gulp.src(pugPaths.src)
.pipe(plumber(error => {
console.log(error);
this.emit('end');
}))
.pipe(data(() => {
return require(`./data/${argv.l}/_project.json`);
}))
.pipe(pug({
locals: {},
pretty: true,
}))
.pipe(rename({
basename: 'index',
}))
.pipe(gulp.dest(dirs.dest))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('views:dev', () => {
gulp.src('./src/browser/views/*.pug')
.pipe(jade({
locals: { env: 'dev' }
}))
.pipe(gulp.dest('./dev'));
});
gulp.task('build-pug', () => {
gutil.log('\n\nBuild pug Paths: \n', pugDir, '\n\n');
var PUG_LOCALS = {
title: pkg.name,
description: pkg.description,
author: pkg.author
};
return gulp.src(pugDir)
.pipe(pug({ locals: PUG_LOCALS }).on('error', onError))
.pipe(gulp.dest(outputPaths.pug))
.pipe(connect.reload());
});
gulp.task('pug', ['clean'], () =>
gulp.src('test/*.pug')
.pipe(pug())
.pipe(gulp.dest('.tmp'))
);
gulp.task('buildPug', () => {
const locals = {
description: pkg.description,
author: pkg.author,
data: {},
};
fs.readdirSync(dataPath).filter(file => file.endsWith('.js')).forEach(file => {
const name = file.slice(0, -3);
const filePath = path.join(dataPath, file);
delete require.cache[require.resolve(filePath)];
locals.data[name] = require(filePath);
});
return gulp
.src(path.join(pugPath, 'index.pug'))
.pipe(pug({ locals }))
.pipe(gulp.dest(builtPath))
.pipe(connect.reload());
});
gulp.task('templates', () => {
return gulp.src([routes.templates.pug, '!' + routes.templates._pug])
.pipe(plumber({
errorHandler: notify.onError({
title: 'Error: Compiling pug.',
message: '<%= error.message %>'
})
}))
.pipe(pug())
.pipe(gulp.dest(routes.files.html))
.pipe(browserSync.stream())
.pipe(notify({
title: 'Pug Compiled succesfully!',
message: 'Pug task completed.'
}));
});
gulp.task('pug', () => {
return gulp.src([srcBase + 'pug/**/*.pug', srcBase + 'pug/**/_*.pug'])
.pipe(plumber())
.pipe(pug({
pretty: true,
locals: {
title: 'gl' + options.gl,
}
}))
.pipe(gulp.dest('./public/gl/'));
});
Gulp.task('resources:build:index', () => {
return Gulp.src('source/web/themes/' + Config.hotel.theme + '/structure.page')
.pipe(Pug())
.pipe(Gulp.dest('dist/'))
})
gulp.task('pug-dev', () =>
gulp.src('./src/pug/pages/**/*.pug')
.pipe(plumber())
.pipe(pug({
pretty: true,
basedir: './src/pug'
}))
.pipe(gulp.dest('./public'))
)