Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions build/gulp/tasks/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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', () =>
Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another problem that I might see here is that if file will be removed, it will still remain to be part of the stream - and this will result in non-relevant produced result.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for some reason this 'unlink' event doesn't fire on my machine - seems to be an issue with 'chokidar' lib (while for 'change' events everything works). This was, essentially, the reason to ask - thanks!

.pipe(gulpExampleMenu())
.pipe(dest(paths.docsSrc('exampleMenus'))),
)
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as path from 'path'
import * as _ from 'lodash'

// ------------------------------------
// Environment vars
Expand Down Expand Up @@ -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, '/'))
Copy link
Contributor

@kuzhelov kuzhelov Sep 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems that we should consider it to be a mandatory preprocessing method for provided values, so that for paths we would have POSIX ones by default:

const paths = posix({
   src: ...,
   dist: ...,
   ...
})

// and then
paths.src()    // returns POSIX variant by default

// and, if it will be necessary, we can do the following (this will be about extending functionality of 'posix()')
paths.original.src()

The reason I see it being a better approach is that we will be provided with a safe defaults as a result - in contrast to the approach that is currently suggested. What do you think?


const config = {
...envConfig,
paths,
Expand Down