Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
On tailwind error prevent crash and show message (#156)
Brad Cornes <bradlc41@gmail.com>
4 years ago
1 changed files, 24 additions(+), 29 deletions(-)
src/class-names/index.js
M src/class-names/index.jssrc/class-names/index.js
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
diff --git a/src/class-names/index.js b/src/class-names/index.js
index 83a15b11a214b931a6e04f569b3d5da5295eda55..c456d5bdd640dc47f80cbcc4fa49cde3697d206f 100644
--- a/src/class-names/index.js
+++ b/src/class-names/index.js
@@ -17,17 +17,6 @@ import { getUtilityConfigMap } from './getUtilityConfigMap'
 import glob from 'fast-glob'
 import normalizePath from 'normalize-path'
 
-function TailwindConfigError(error) {
-  Error.call(this)
-  Error.captureStackTrace(this, this.constructor)
-
-  this.name = this.constructor.name
-  this.message = error.message
-  this.stack = error.stack
-}
-
-util.inherits(TailwindConfigError, Error)
-
 function arraysEqual(arr1, arr2) {
   return (
     JSON.stringify(arr1.concat([]).sort()) ===
@@ -98,23 +87,34 @@     let config
     try {
       config = __non_webpack_require__(configPath)
     } catch (error) {
-      throw new TailwindConfigError(error)
+      hook.unwatch()
+      hook.unhook()
+      throw error
     }
+
     hook.unwatch()
 
-    const [base, components, utilities] = await Promise.all(
-      [
-        semver.gte(version, '0.99.0') ? 'base' : 'preflight',
-        'components',
-        'utilities',
-      ].map((group) =>
-        postcss([tailwindcss(configPath)]).process(`@tailwind ${group};`, {
-          from: undefined,
-        })
+    let postcssResult
+
+    try {
+      postcssResult = await Promise.all(
+        [
+          semver.gte(version, '0.99.0') ? 'base' : 'preflight',
+          'components',
+          'utilities',
+        ].map((group) =>
+          postcss([tailwindcss(configPath)]).process(`@tailwind ${group};`, {
+            from: undefined,
+          })
+        )
       )
-    )
+    } catch (error) {
+      throw error
+    } finally {
+      hook.unhook()
+    }
 
-    hook.unhook()
+    const [base, components, utilities] = postcssResult
 
     if (typeof userSeperator !== 'undefined') {
       dset(config, sepLocation, userSeperator)
@@ -180,12 +180,7 @@     const prevDeps = result ? [result.configPath, ...result.dependencies] : []
     try {
       result = await run()
     } catch (error) {
-      if (error instanceof TailwindConfigError) {
-        onChange({ error })
-      } else {
-        unwatch()
-        onChange(null)
-      }
+      onChange({ error })
       return
     }
     const newDeps = [result.configPath, ...result.dependencies]