Skip to content

Commit 2e1defb

Browse files
committed
Cleanup server logs
1 parent 78e3db5 commit 2e1defb

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

Plugins/VercelPackager/VercelOutput.swift

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,11 @@ public struct VercelOutput {
8686
)
8787

8888
Task {
89-
var env = localEnvironment()
90-
env["LOCAL_LAMBDA_SERVER_ENABLED"] = "true"
91-
92-
try Shell.execute(
93-
executable: context.tool(named: "swift").path,
94-
arguments: ["run", "--package-path", projectDirectory.string],
95-
environment: env
96-
)
89+
try startSwiftAppServer()
9790
}
9891

9992
Task {
100-
try await proxyServer()
93+
try startNodeProxyServer()
10194
}
10295

10396
try await Task.sleep(nanoseconds: 3_000_000_000)
@@ -124,15 +117,7 @@ public struct VercelOutput {
124117
print("")
125118
print("")
126119

127-
try Shell.execute(
128-
executable: context.tool(named: "node").path,
129-
arguments: [
130-
projectDirectory.appending([".build", "checkouts", "Vercel", "Plugins", "VercelPackager", "Server", "server.cjs"]).string,
131-
port
132-
],
133-
environment: ["SWIFT_PROJECT_DIRECTORY": projectDirectory.string],
134-
printCommand: false
135-
)
120+
try startNodeProxyServer()
136121
}
137122
}
138123

@@ -487,6 +472,34 @@ extension VercelOutput {
487472
}
488473
}
489474

475+
// MARK: - Server
476+
477+
extension VercelOutput {
478+
479+
public func startSwiftAppServer() throws {
480+
var env = localEnvironment()
481+
env["LOCAL_LAMBDA_SERVER_ENABLED"] = "true"
482+
483+
try Shell.execute(
484+
executable: context.tool(named: "swift").path,
485+
arguments: ["run", "--package-path", projectDirectory.string],
486+
environment: env
487+
)
488+
}
489+
490+
public func startNodeProxyServer() throws {
491+
try Shell.execute(
492+
executable: context.tool(named: "node").path,
493+
arguments: [
494+
projectDirectory.appending([".build", "checkouts", "Vercel", "Plugins", "VercelPackager", "Server", "server.cjs"]).string,
495+
port
496+
],
497+
environment: ["SWIFT_PROJECT_DIRECTORY": projectDirectory.string],
498+
printCommand: false
499+
)
500+
}
501+
}
502+
490503
// MARK: - Build
491504

492505
extension VercelOutput {

0 commit comments

Comments
 (0)