diff --git a/build/gulp/tasks/docs.ts b/build/gulp/tasks/docs.ts index e4284d6b4a..0ff09357fc 100644 --- a/build/gulp/tasks/docs.ts +++ b/build/gulp/tasks/docs.ts @@ -20,7 +20,11 @@ const { paths } = config const g = require('gulp-load-plugins')() const { colors, log, PluginError } = g.util -const handleWatchChange = (path, stats) => log(`File ${path} was changed, running tasks...`) +const handleWatchChange = path => log(`File ${path} was changed, running tasks...`) +const handleWatchUnlink = (group, path) => { + log(`File ${path} was deleted, running tasks...`) + remember.forget(group, path) +} // ---------------------------------------- // Clean @@ -61,9 +65,9 @@ task( // Build // ---------------------------------------- -const componentsSrc = [`${config.paths.src()}/components/*/[A-Z]*.tsx`] -const behaviorSrc = [`${config.paths.src()}/lib/accessibility/Behaviors/*/[A-Z]*.ts`] -const examplesSrc = `${paths.docsSrc()}/examples/*/*/*/index.tsx` +const componentsSrc = [`${paths.posix.src()}/components/*/[A-Z]*.tsx`] +const behaviorSrc = [`${paths.posix.src()}/lib/accessibility/Behaviors/*/[A-Z]*.ts`] +const examplesSrc = `${paths.posix.docsSrc()}/examples/*/*/*/index.tsx` const markdownSrc = ['.github/CONTRIBUTING.md', 'specifications/*.md'] task('build:docs:docgen', () => @@ -87,6 +91,7 @@ task('build:docs:component-menu-behaviors', () => task('build:docs:example-menu', () => src(examplesSrc, { since: lastRun('build:docs:example-menu') }) + .pipe(remember('example-menu')) // FIXME: with watch this unnecessarily processes index files for all examples .pipe(gulpExampleMenu()) .pipe(dest(paths.docsSrc('exampleMenus'))), ) @@ -211,14 +216,13 @@ task('watch:docs', cb => { watch(componentsSrc, series('build:docs:docgen')).on('change', handleWatchChange) // rebuild example menus - watch(examplesSrc, series('build:docs:example-menu')).on('change', handleWatchChange) + watch(examplesSrc, series('build:docs:example-menu')) + .on('change', handleWatchChange) + .on('unlink', path => handleWatchUnlink('example-menu', path)) watch(behaviorSrc, series('build:docs:component-menu-behaviors')) .on('change', handleWatchChange) - .on('unlink', path => { - log(`File ${path} was deleted, running tasks...`) - remember.forget('component-menu-behaviors', path) - }) + .on('unlink', path => handleWatchUnlink('component-menu-behaviors', path)) // rebuild images watch(`${config.paths.src()}/**/*.{png,jpg,gif}`, series('build:docs:images')).on( diff --git a/config.ts b/config.ts index d4d6f2bf4a..aaff75c7b1 100644 --- a/config.ts +++ b/config.ts @@ -1,4 +1,5 @@ import * as path from 'path' +import * as _ from 'lodash' // ------------------------------------ // Environment vars @@ -36,8 +37,11 @@ const paths = { docsDist: base.bind(null, envConfig.dir_docs_dist), docsSrc: base.bind(null, envConfig.dir_docs_src), umdDist: base.bind(null, envConfig.dir_umd_dist), + posix: undefined, // all the sibling values, but with forward slashes regardless the OS } +paths.posix = _.mapValues(paths, func => (...args) => func(...args).replace(/\\/g, '/')) + const config = { ...envConfig, paths,