Commit 12493e37 authored by Dan Allen's avatar Dan Allen

move gulpfile.js into gulpfile.js folder

parent 260cc898
......@@ -2,9 +2,9 @@
const { parallel, series, tree } = require('gulp')
const camelcase = (name) => name.replace(/[-]./g, (m) => m.substr(1).toUpperCase())
const exportTasks = require('./tasks/lib/export-tasks')
const task = require('./tasks/lib/task')
const taskFns = require('require-directory')(module, './tasks', { recurse: false, rename: camelcase })
const exportTasks = require('./lib/export-tasks')
const task = require('./lib/task')
const taskFns = require('require-directory')(module, '.', { recurse: false, rename: camelcase })
const path = require('path')
const bundleName = 'ui'
......@@ -16,7 +16,7 @@ const destDir = path.join(previewSiteDestDir, '_')
const { reload: livereload } = process.env.LIVERELOAD === 'true' ? require('gulp-connect') : {}
const cssFileGlobs = path.join(srcDir, 'css/**/*.css')
const jsFileGlobs = ['gulpfile.js', 'tasks/**/*.js', path.join(srcDir, '{helpers,js}/**/*.js')]
const jsFileGlobs = ['gulpfile.js/**/*.js', path.join(srcDir, '{helpers,js}/**/*.js')]
const { remove, lintCss, lintJs, format, build, pack, previewPages, previewServe } = taskFns
......
......@@ -9,29 +9,25 @@ const vfs = require('vinyl-fs')
const yaml = require('js-yaml')
module.exports = (src, dest, siteSrc, siteDest, onComplete) => () =>
Promise.all([
loadSampleUiModel(siteSrc),
compileLayouts(src),
registerPartials(src),
registerHelpers(src),
]).then(([uiModel, layouts]) =>
vfs
.src('**/*.html', { base: siteSrc, cwd: siteSrc })
.pipe(
map((file, enc, next) => {
const compiledLayout = layouts[file.stem === '404' ? '404.hbs' : 'default.hbs']
const siteRootPath = path.relative(path.dirname(file.path), path.resolve(siteSrc))
uiModel.env = process.env
uiModel.siteRootPath = siteRootPath
uiModel.siteRootUrl = path.join(siteRootPath, 'index.html')
uiModel.uiRootPath = path.join(siteRootPath, '_')
uiModel.page.contents = file.contents.toString().trim()
file.contents = Buffer.from(compiledLayout(uiModel))
next(null, file)
})
)
.pipe(vfs.dest(siteDest))
.pipe(onComplete ? onComplete() : map((file, enc, next) => next()))
Promise.all([loadSampleUiModel(siteSrc), compileLayouts(src), registerPartials(src), registerHelpers(src)]).then(
([uiModel, layouts]) =>
vfs
.src('**/*.html', { base: siteSrc, cwd: siteSrc })
.pipe(
map((file, enc, next) => {
const compiledLayout = layouts[file.stem === '404' ? '404.hbs' : 'default.hbs']
const siteRootPath = path.relative(path.dirname(file.path), path.resolve(siteSrc))
uiModel.env = process.env
uiModel.siteRootPath = siteRootPath
uiModel.siteRootUrl = path.join(siteRootPath, 'index.html')
uiModel.uiRootPath = path.join(siteRootPath, '_')
uiModel.page.contents = file.contents.toString().trim()
file.contents = Buffer.from(compiledLayout(uiModel))
next(null, file)
})
)
.pipe(vfs.dest(siteDest))
.pipe(onComplete ? onComplete() : map((file, enc, next) => next()))
)
function loadSampleUiModel (siteSrc) {
......
'use strict'
const fs = require('fs-extra')
const { obj: map } = require('through2')
const vfs = require('vinyl-fs')
module.exports = (files) => () =>
vfs.src(files, { allowEmpty: true }).pipe(map((file, enc, next) => fs.remove(file.path, next)))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment