diff --git a/packages/tailwindcss-class-names/package-lock.json b/packages/tailwindcss-class-names/package-lock.json
index 6f9f6f4b718594d40dd08bd1712984a2e5e7a4ae..3e0ef2d7ab1d8af5b495c77cc5c32a3319b3c4a6 100644
--- a/packages/tailwindcss-class-names/package-lock.json
+++ b/packages/tailwindcss-class-names/package-lock.json
@@ -1115,7 +1115,8 @@ },
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
- "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
+ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
+ "dev": true
},
"base": {
"version": "0.11.2",
@@ -1190,6 +1191,7 @@ "brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+ "dev": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -1422,7 +1424,8 @@ },
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
- "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
+ "dev": true
},
"convert-source-map": {
"version": "1.7.0",
@@ -2022,9 +2025,9 @@ },
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz",
"name": "tailwindcss-class-names",
- "dependencies": {
+ "@types/istanbul-lib-coverage": "*",
+ "dev": true
},
"fsevents": {
"version": "2.1.2",
@@ -2079,6 +2082,8 @@ "version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
{
+{
+{
"name": "tailwindcss-class-names",
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@@ -2102,6 +2107,16 @@ "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
"integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==",
"dev": true
},
+ "globalyzer": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.4.tgz",
+ "integrity": "sha512-LeguVWaxgHN0MNbWC6YljNMzHkrCny9fzjmEUdnF1kQ7wATFD1RHFRqA1qxaX2tgxGENlcxjOflopBwj3YZiXA=="
+ },
+ "globrex": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
+ "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg=="
+ },
"graceful-fs": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz",
@@ -2279,6 +2294,8 @@ "version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
{
+{
+{
"name": "tailwindcss-class-names",
"once": "^1.3.0",
"wrappy": "1"
@@ -2287,7 +2304,8 @@ },
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
- "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
+ "dev": true
},
"ip-regex": {
"version": "2.1.0",
@@ -4062,6 +4080,8 @@ "version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
{
+{
+{
"name": "tailwindcss-class-names",
"brace-expansion": "^1.1.7"
}
@@ -4288,6 +4308,8 @@ "version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
{
+{
+{
"name": "tailwindcss-class-names",
"wrappy": "1"
}
@@ -4370,10 +4392,10 @@ },
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
-{
+ "integrity": "sha512-Eu3dysBzSAO1lD7cylZd/CVKdZZ1/43SF35iYBNV1Lvvn2Undp3Grwsv8PrzvbLhqwRzDd4zxrY4gsiHc+wygQ==",
"dependencies": {
"version": "7.8.3",
- "requires": true,
+ "name": "tailwindcss-class-names",
},
"path-key": {
"version": "2.0.1",
@@ -5761,9 +5782,9 @@ "wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"name": "tailwindcss-class-names",
- "name": "tailwindcss-class-names",
+ "integrity": "sha512-9T1auFmbPZoxHz0enUFlUuKRy3it01R+hlggyVUMtnCTQRunsQYifnSGb8hET4Xo8yiC0o0r1paW3ud5+rbURg==",
"version": "7.8.3",
- "version": "0.0.1",
+ "name": "tailwindcss-class-names",
},
"write-file-atomic": {
"version": "3.0.3",
diff --git a/packages/tailwindcss-class-names/src/globSingle.js b/packages/tailwindcss-class-names/src/globSingle.js
new file mode 100644
index 0000000000000000000000000000000000000000..91d10fbdafa520b34f83fec768addd95eb26f444
--- /dev/null
+++ b/packages/tailwindcss-class-names/src/globSingle.js
@@ -0,0 +1,105 @@
+const fs = require('fs')
+const globrex = require('globrex')
+const { promisify } = require('util')
+const globalyzer = require('globalyzer')
+const { join, resolve, relative } = require('path')
+const isHidden = /(^|[\\\/])\.[^\\\/\.]/g
+const readdir = promisify(fs.readdir)
+const stat = promisify(fs.stat)
+let CACHE = {}
+
+async function walk(output, prefix, lexer, opts, dirname = '', level = 0) {
+ if (output.length === 1) return
+ const rgx = lexer.segments[level]
+ const dir = join(opts.cwd, prefix, dirname)
+ const files = await readdir(dir)
+ const { dot, filesOnly } = opts
+
+ let i = 0,
+ len = files.length,
+ file
+ let fullpath, relpath, stats, isMatch
+
+ for (; i < len; i++) {
+ file = files[i]
+ if (file === 'node_modules') continue
+ fullpath = join(dir, file)
+ relpath = dirname ? join(dirname, file) : file
+ if (!dot && isHidden.test(relpath)) continue
+ isMatch = lexer.regex.test(relpath)
+
+ if ((stats = CACHE[relpath]) === void 0) {
+ CACHE[relpath] = stats = fs.lstatSync(fullpath)
+ }
+
+ if (!stats.isDirectory()) {
+ if (isMatch) {
+ output.push(relative(opts.cwd, fullpath))
+ return
+ }
+ continue
+ }
+
+ if (rgx && !rgx.test(file)) continue
+ if (!filesOnly && isMatch) {
+ output.push(join(prefix, relpath))
+ return
+ }
+
+ await walk(
+ output,
+ prefix,
+ lexer,
+ opts,
+ relpath,
+ rgx && rgx.toString() !== lexer.globstar && ++level
+ )
+ }
+}
+
+/**
+ * Find files using bash-like globbing.
+ * All paths are normalized compared to node-glob.
+ * @param {String} str Glob string
+ * @param {String} [options.cwd='.'] Current working directory
+ * @param {Boolean} [options.dot=false] Include dotfile matches
+ * @param {Boolean} [options.absolute=false] Return absolute paths
+ * @param {Boolean} [options.filesOnly=false] Do not include folders if true
+ * @param {Boolean} [options.flush=false] Reset cache object
+ * @returns {Array} array containing matching files
+ */
+export async function globSingle(str, opts = {}) {
+ if (!str) return []
+
+ let glob = globalyzer(str)
+
+ opts.cwd = opts.cwd || '.'
+
+ if (!glob.isGlob) {
+ try {
+ let resolved = resolve(opts.cwd, str)
+ let dirent = await stat(resolved)
+ if (opts.filesOnly && !dirent.isFile()) return []
+
+ return opts.absolute ? [resolved] : [str]
+ } catch (err) {
+ if (err.code != 'ENOENT') throw err
+
+ return []
+ }
+ }
+
+ if (opts.flush) CACHE = {}
+
+ let matches = []
+ const { path } = globrex(glob.glob, {
+ filepath: true,
+ globstar: true,
+ extended: true,
+ })
+
+ path.globstar = path.globstar.toString()
+ await walk(matches, glob.base, path, opts, '.', 0)
+
+ return opts.absolute ? matches.map((x) => resolve(opts.cwd, x)) : matches
+}