@srfnstack/spliffy 0.9.1 → 0.9.2
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.
- package/package.json +2 -2
- package/src/routes.mjs +12 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@srfnstack/spliffy",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"author": "snowbldr",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/narcolepticsnowman/spliffy",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"standard": "^16.0.4",
|
|
40
40
|
"helmet": "^4.6.0",
|
|
41
41
|
"jest": "^27.3.1",
|
|
42
|
-
"node-fetch": "^2.6.
|
|
42
|
+
"node-fetch": "^2.6.7"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/src/routes.mjs
CHANGED
|
@@ -44,6 +44,16 @@ const doFindRoutes = async (config, currentFile, filePath, urlPath, pathParamete
|
|
|
44
44
|
return routes
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
const wrapSyntaxError = (e, path) => {
|
|
48
|
+
// Hack to workaround https://github.com/nodejs/modules/issues/471
|
|
49
|
+
if (e instanceof SyntaxError) {
|
|
50
|
+
const newError = new SyntaxError(`${e.message}. In file: ${path}`)
|
|
51
|
+
newError.stack += `\nCaused By: ${e.stack}`
|
|
52
|
+
throw newError
|
|
53
|
+
}
|
|
54
|
+
throw e
|
|
55
|
+
}
|
|
56
|
+
|
|
47
57
|
const importModules = async (config, dirPath, files) => Promise.all(
|
|
48
58
|
files
|
|
49
59
|
.filter(filterTestFiles(config))
|
|
@@ -51,14 +61,7 @@ const importModules = async (config, dirPath, files) => Promise.all(
|
|
|
51
61
|
.map(f => path.join(dirPath, f.name))
|
|
52
62
|
.map(mwPath => import(`file://${mwPath}`)
|
|
53
63
|
.then(module => ({ module, mwPath }))
|
|
54
|
-
.catch(e =>
|
|
55
|
-
// Hack to workaround https://github.com/nodejs/modules/issues/471
|
|
56
|
-
if (e instanceof SyntaxError) {
|
|
57
|
-
const newError = new SyntaxError(`${e.message}. In file: ${mwPath}`)
|
|
58
|
-
newError.stack = e.stack
|
|
59
|
-
throw newError
|
|
60
|
-
}
|
|
61
|
-
})
|
|
64
|
+
.catch(e => wrapSyntaxError(e, mwPath))
|
|
62
65
|
))
|
|
63
66
|
|
|
64
67
|
const findRoutesInDir = async (name, filePath, urlPath, inheritedMiddleware, pathParameters, config) => {
|
|
@@ -118,12 +121,7 @@ const buildJSHandlerRoute = async (name, filePath, urlPath, inheritedMiddleware,
|
|
|
118
121
|
try {
|
|
119
122
|
module = await import(`file://${filePath}`)
|
|
120
123
|
} catch (e) {
|
|
121
|
-
|
|
122
|
-
if (e instanceof SyntaxError) {
|
|
123
|
-
const newError = new SyntaxError(`${e.message}. In file: ${filePath}`)
|
|
124
|
-
newError.stack = e.stack
|
|
125
|
-
throw newError
|
|
126
|
-
}
|
|
124
|
+
wrapSyntaxError(e, filePath)
|
|
127
125
|
}
|
|
128
126
|
const handlers = module.default
|
|
129
127
|
try {
|