Commit ce962886 authored by Dan Allen's avatar Dan Allen

copy images for preview site

parent 1fa15ac7
......@@ -73,7 +73,7 @@ const bundleTask = task({
const previewPagesTask = task({
name: 'preview:pages',
call: previewPages(srcDir, destDir, previewSrcDir, previewDestDir, livereload),
call: previewPages(srcDir, previewSrcDir, previewDestDir, livereload),
})
const previewBuildTask = task({
......
......@@ -18,16 +18,16 @@ const ASCIIDOC_ATTRIBUTES = {
'source-highlighter': 'highlight.js',
}
module.exports = (src, dest, siteSrc, siteDest, sink = () => map(), layouts = {}) => () =>
module.exports = (src, previewSrc, previewDest, sink = () => map(), layouts = {}) => () =>
Promise.all([
loadSampleUiModel(siteSrc),
toPromise(merge(compileLayouts(src, layouts), registerPartials(src), registerHelpers(src))),
loadSampleUiModel(previewSrc),
toPromise(merge(compileLayouts(src, layouts), registerPartials(src), registerHelpers(src), copyImages(previewSrc, previewDest))),
]).then(([baseUiModel]) => Object.assign(baseUiModel, { env: process.env })).then((baseUiModel) =>
vfs
.src('**/*.adoc', { base: siteSrc, cwd: siteSrc })
.src('**/*.adoc', { base: previewSrc, cwd: previewSrc })
.pipe(
map((file, enc, next) => {
const siteRootPath = path.relative(ospath.dirname(file.path), ospath.resolve(siteSrc))
const siteRootPath = path.relative(ospath.dirname(file.path), ospath.resolve(previewSrc))
const uiModel = Object.assign({}, baseUiModel)
uiModel.page = Object.assign({}, uiModel.page)
uiModel.siteRootPath = siteRootPath
......@@ -52,12 +52,12 @@ module.exports = (src, dest, siteSrc, siteDest, sink = () => map(), layouts = {}
next(null, file)
})
)
.pipe(vfs.dest(siteDest))
.pipe(vfs.dest(previewDest))
.pipe(sink())
)
function loadSampleUiModel (siteSrc) {
return fs.readFile(ospath.join(siteSrc, 'ui-model.yml'), 'utf8').then((contents) => yaml.safeLoad(contents))
function loadSampleUiModel (src) {
return fs.readFile(ospath.join(src, 'ui-model.yml'), 'utf8').then((contents) => yaml.safeLoad(contents))
}
function registerPartials (src) {
......@@ -87,6 +87,10 @@ function compileLayouts (src, layouts) {
)
}
function copyImages (src, dest) {
return vfs.src('**/*.{png,svg}', { base: src, cwd: src }).pipe(vfs.dest(dest))
}
function toPromise (stream) {
return new Promise((resolve, reject) => stream.on('error', reject).on('finish', resolve))
}
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