Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize CLI content globs #5628

Merged
merged 3 commits into from
Sep 29, 2021
Merged
Changes from 1 commit
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
15 changes: 9 additions & 6 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import fastGlob from 'fast-glob'
import getModuleDependencies from './lib/getModuleDependencies'
import log from './util/log'
import packageJson from '../package.json'
import normalizePath from 'normalize-path'

let env = {
DEBUG: process.env.DEBUG !== undefined,
Expand Down Expand Up @@ -437,12 +438,14 @@ async function build() {
}

function extractFileGlobs(config) {
Copy link
Member

Choose a reason for hiding this comment

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

We use this function in both the `getChangedContent.

tailwindcss/src/cli.js

Lines 461 to 462 in 2ab6e6e

let globs = extractFileGlobs(config)
let files = fastGlob.sync(globs)

But we also use this function when setting up the chokidar watcher:

watcher = chokidar.watch([...contextDependencies, ...extractFileGlobs(config)], {

And I wonder if this causes issues, because now we are passing normalized paths to chokidar. Do you know if chokidar can handle C:/../ instead of C:\..\? 🤔

Ah nvm, it fixes chokidar as well: https://github.com/paulmillr/chokidar#api

Note: globs must not contain windows separators (), because that's how they work by the standard — you'll need to replace them with forward slashes (/).

Nice!

return extractContent(config).filter((file) => {
// Strings in this case are files / globs. If it is something else,
// like an object it's probably a raw content object. But this object
// is not watchable, so let's remove it.
return typeof file === 'string'
})
return extractContent(config)
.filter((file) => {
// Strings in this case are files / globs. If it is something else,
// like an object it's probably a raw content object. But this object
// is not watchable, so let's remove it.
return typeof file === 'string'
})
.map((glob) => normalizePath(glob))
}

function extractRawContent(config) {
Expand Down