Skip to content

Commit

Permalink
rejig config finder (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradlc committed Jun 24, 2020
1 parent c5b5c1b commit 9f003fe
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 137 deletions.
67 changes: 67 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
"dlv": "^1.1.3",
"dset": "^2.0.1",
"esm": "^3.2.25",
"fast-glob": "^3.2.4",
"glob-exec": "^0.1.1",
"globalyzer": "^0.1.4",
"globrex": "^0.1.2",
Expand All @@ -179,6 +180,7 @@
"mitt": "^1.2.0",
"mkdirp": "^1.0.3",
"moo": "^0.5.1",
"normalize-path": "^3.0.0",
"pkg-up": "^3.1.0",
"postcss": "^7.0.27",
"postcss-selector-parser": "^6.0.2",
Expand Down
22 changes: 0 additions & 22 deletions src/class-names/glob.js

This file was deleted.

105 changes: 0 additions & 105 deletions src/class-names/globSingle.js

This file was deleted.

26 changes: 16 additions & 10 deletions src/class-names/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import getVariants from './getVariants'
import resolveConfig from './resolveConfig'
import * as util from 'util'
import * as path from 'path'
import { globSingle } from './globSingle'
import { getUtilityConfigMap } from './getUtilityConfigMap'
import glob from 'fast-glob'
import normalizePath from 'normalize-path'

function TailwindConfigError(error) {
Error.call(this)
Expand Down Expand Up @@ -41,20 +42,25 @@ export default async function getClassNames(
{ onChange = () => {} } = {}
) {
async function run() {
let configPath
let postcss
let tailwindcss
let browserslistModule
let version

configPath = await globSingle(CONFIG_GLOB, {
cwd,
filesOnly: true,
absolute: true,
flush: true,
})
invariant(configPath.length === 1, 'No Tailwind CSS config found.')
configPath = configPath[0]
const configPaths = (
await glob(CONFIG_GLOB, {
cwd,
ignore: ['**/node_modules'],
onlyFiles: true,
absolute: true,
})
)
.map(normalizePath)
.sort((a, b) => a.split('/').length - b.split('/').length)
.map(path.normalize)

invariant(configPaths.length > 0, 'No Tailwind CSS config found.')
const configPath = configPaths[0]
const configDir = path.dirname(configPath)
const tailwindBase = path.dirname(
resolveFrom(configDir, 'tailwindcss/package.json')
Expand Down

0 comments on commit 9f003fe

Please sign in to comment.