Skip to content

Commit 5371475

Browse files
authored
Merge pull request #23 from ericclemmons/23-root-wildcard
index.*.js doesn't work as expected on the root
2 parents 1ba315e + aebe985 commit 5371475

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

packages/polydev/src/middleware/router/createRouterFromFiles.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ module.exports = function createRouterFromFiles(routesPath, files) {
4242
case "*":
4343
handle(router, file, [
4444
["GET", route],
45-
["GET", `${route}/*`],
45+
["GET", path.join(route, "*")],
4646
["POST", route],
47-
["POST", `${route}/*`]
47+
["POST", path.join(route, "*")]
4848
])
4949
break
5050

packages/polydev/src/middleware/router/launcher.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ require("hot-module-replacement")({
99
ignore: /node_modules/ // regexp to decide if module should be ignored; also can be a function accepting string and returning true/false
1010
})
1111

12+
const { spawn } = require("child_process")
1213
const express = require("express")
14+
const path = require("path")
1315

1416
const bridge = require("./bridge")
1517

@@ -79,12 +81,21 @@ async function startHandler() {
7981
app.listen(PORT, async () => {
8082
console.log(`↩︎ ${handlerPath.replace(process.cwd(), ".")} from ${url}`)
8183
})
84+
} else if (typeof handler === "string") {
85+
// Expected to have path to `package.json`
86+
const pkg = require(handler)
87+
const cwd = path.dirname(handler)
88+
89+
spawn("yarn", [pkg.scripts.dev ? "dev" : "start"], {
90+
cwd,
91+
stdio: "inherit"
92+
})
8293
} else {
8394
console.warn(
8495
`${handlerPath.replace(
8596
process.cwd(),
8697
"."
87-
)} does not return a Function, Server, or path to package.json`
98+
)} does not return a Function, Server, or path to a package.json`
8899
)
89100
// In development, at least listen on PORT so that we can 404
90101
express().listen(PORT)

0 commit comments

Comments
 (0)