@vituum/vite-plugin-pug 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +7 -6
  2. package/package.json +4 -4
package/index.js CHANGED
@@ -26,7 +26,9 @@ function processData(paths, data = {}) {
26
26
 
27
27
  lodash.merge(context, data)
28
28
 
29
- FastGlob.sync(paths).forEach(entry => {
29
+ const normalizePaths = Array.isArray(paths) ? paths.map(path => path.replace(/\\/g, '/')) : paths.replace(/\\/g, '/')
30
+
31
+ FastGlob.sync(normalizePaths).forEach(entry => {
30
32
  const path = resolve(process.cwd(), entry)
31
33
 
32
34
  context = lodash.merge(context, JSON.parse(fs.readFileSync(path).toString()))
@@ -51,8 +53,7 @@ const renderTemplate = async(filename, content, options) => {
51
53
  console.error(chalk.red(name + ' template must be defined - ' + filename))
52
54
  }
53
55
 
54
- context.template = relative(process.cwd(), context.template).startsWith(relative(process.cwd(), options.root))
55
- ? resolve(process.cwd(), context.template) : resolve(options.root, context.template)
56
+ context.template = relative(process.cwd(), context.template).startsWith(relative(process.cwd(), options.root)) ? resolve(process.cwd(), context.template) : resolve(options.root, context.template)
56
57
  } else if (fs.existsSync(filename + '.json')) {
57
58
  lodash.merge(context, JSON.parse(fs.readFileSync(filename + '.json').toString()))
58
59
  }
@@ -64,7 +65,7 @@ const renderTemplate = async(filename, content, options) => {
64
65
  }))
65
66
 
66
67
  output.content = template(context)
67
- } catch(error) {
68
+ } catch (error) {
68
69
  output.error = error
69
70
  }
70
71
 
@@ -111,13 +112,13 @@ const plugin = (options = {}) => {
111
112
  return
112
113
  }
113
114
 
114
- server.ws.send({
115
+ setTimeout(() => server.ws.send({
115
116
  type: 'error',
116
117
  err: {
117
118
  message: render.error.message,
118
119
  plugin: name
119
120
  }
120
- })
121
+ }), 50)
121
122
  }
122
123
 
123
124
  return render.content
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@vituum/vite-plugin-pug",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "dependencies": {
7
7
  "pug": "^3.0.2",
8
8
  "lodash": "^4.17.21",
9
- "chalk": "^5.0.1",
10
- "fast-glob": "^3.2.11"
9
+ "chalk": "^5.2.0",
10
+ "fast-glob": "^3.2.12"
11
11
  },
12
12
  "devDependencies": {
13
- "eslint": "^8.23.0",
13
+ "eslint": "^8.29.0",
14
14
  "eslint-config-standard": "^17.0.0"
15
15
  },
16
16
  "files": [