From 12493e37c9f8f49c52afd6b166f9048083466121 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Thu, 27 Dec 2018 04:58:37 -0700 Subject: [PATCH] move gulpfile.js into gulpfile.js folder --- {tasks => gulpfile.js}/build.js | 0 {tasks => gulpfile.js}/format.js | 0 gulpfile.js => gulpfile.js/index.js | 8 ++--- {tasks => gulpfile.js}/lib/export-tasks.js | 0 {tasks => gulpfile.js}/lib/gulp-prettier-eslint.js | 0 {tasks => gulpfile.js}/lib/task.js | 0 {tasks => gulpfile.js}/lint-css.js | 0 {tasks => gulpfile.js}/lint-js.js | 0 {tasks => gulpfile.js}/pack.js | 0 {tasks => gulpfile.js}/preview-pages.js | 42 ++++++++++------------ {tasks => gulpfile.js}/preview-serve.js | 0 gulpfile.js/remove.js | 8 +++++ 12 files changed, 31 insertions(+), 27 deletions(-) rename {tasks => gulpfile.js}/build.js (100%) rename {tasks => gulpfile.js}/format.js (100%) rename gulpfile.js => gulpfile.js/index.js (91%) rename {tasks => gulpfile.js}/lib/export-tasks.js (100%) rename {tasks => gulpfile.js}/lib/gulp-prettier-eslint.js (100%) rename {tasks => gulpfile.js}/lib/task.js (100%) rename {tasks => gulpfile.js}/lint-css.js (100%) rename {tasks => gulpfile.js}/lint-js.js (100%) rename {tasks => gulpfile.js}/pack.js (100%) rename {tasks => gulpfile.js}/preview-pages.js (63%) rename {tasks => gulpfile.js}/preview-serve.js (100%) create mode 100644 gulpfile.js/remove.js diff --git a/tasks/build.js b/gulpfile.js/build.js similarity index 100% rename from tasks/build.js rename to gulpfile.js/build.js diff --git a/tasks/format.js b/gulpfile.js/format.js similarity index 100% rename from tasks/format.js rename to gulpfile.js/format.js diff --git a/gulpfile.js b/gulpfile.js/index.js similarity index 91% rename from gulpfile.js rename to gulpfile.js/index.js index d769ad5..9b9bd91 100644 --- a/gulpfile.js +++ b/gulpfile.js/index.js @@ -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 diff --git a/tasks/lib/export-tasks.js b/gulpfile.js/lib/export-tasks.js similarity index 100% rename from tasks/lib/export-tasks.js rename to gulpfile.js/lib/export-tasks.js diff --git a/tasks/lib/gulp-prettier-eslint.js b/gulpfile.js/lib/gulp-prettier-eslint.js similarity index 100% rename from tasks/lib/gulp-prettier-eslint.js rename to gulpfile.js/lib/gulp-prettier-eslint.js diff --git a/tasks/lib/task.js b/gulpfile.js/lib/task.js similarity index 100% rename from tasks/lib/task.js rename to gulpfile.js/lib/task.js diff --git a/tasks/lint-css.js b/gulpfile.js/lint-css.js similarity index 100% rename from tasks/lint-css.js rename to gulpfile.js/lint-css.js diff --git a/tasks/lint-js.js b/gulpfile.js/lint-js.js similarity index 100% rename from tasks/lint-js.js rename to gulpfile.js/lint-js.js diff --git a/tasks/pack.js b/gulpfile.js/pack.js similarity index 100% rename from tasks/pack.js rename to gulpfile.js/pack.js diff --git a/tasks/preview-pages.js b/gulpfile.js/preview-pages.js similarity index 63% rename from tasks/preview-pages.js rename to gulpfile.js/preview-pages.js index d2e7fc9..abc8b98 100644 --- a/tasks/preview-pages.js +++ b/gulpfile.js/preview-pages.js @@ -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) { diff --git a/tasks/preview-serve.js b/gulpfile.js/preview-serve.js similarity index 100% rename from tasks/preview-serve.js rename to gulpfile.js/preview-serve.js diff --git a/gulpfile.js/remove.js b/gulpfile.js/remove.js new file mode 100644 index 0000000..3f71eec --- /dev/null +++ b/gulpfile.js/remove.js @@ -0,0 +1,8 @@ +'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))) -- 2.11.0