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(-)
M src/class-names/index.js -> src/class-names/index.js
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]