Skip to content

Commit

Permalink
fix: detect Node.js runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
manekinekko committed Sep 14, 2020
1 parent f9c6c18 commit bcda33c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 0 additions & 2 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ const startCommand = [
`"(cd ./src/auth/; func start --cors=* --port=${authUriPort})"`,

// serve the app
// See available options for http-server: https://github.com/http-party/http-server#available-options
// Note: --proxy allows us to add fallback routes for SPA (https://github.com/http-party/http-server#catch-all-redirect)
`"${hostCommand} ${hostArgs.join(" ")}"`,

// serve the api, if it's available
Expand Down
3 changes: 3 additions & 0 deletions src/runtimeHost.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { readConfigFile } = require("./utils");
const { detectRuntime, RuntimeType } = require("./runtimes");

const httpServerBin = path.resolve(__dirname, "..", "./node_modules/.bin/http-server");

module.exports.createRuntimeHost = (port, proxyHost, proxyPort) => {
const { app_location, app_artifact_location } = readConfigFile();
const runtimeType = detectRuntime(app_location);
Expand All @@ -16,6 +17,8 @@ module.exports.createRuntimeHost = (port, proxyHost, proxyPort) => {

case RuntimeType.node:
default:
// See available options for http-server: https://github.com/http-party/http-server#available-options
// Note: --proxy allows us to add fallback routes for SPA (https://github.com/http-party/http-server#catch-all-redirect)
const command = httpServerBin;
const args = `${app_artifact_location} -p ${port} -c-1 --proxy http://${proxyHost}:${proxyPort}/?`.split(" ");

Expand Down
2 changes: 1 addition & 1 deletion src/runtimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports.detectRuntime = (app_location) => {
return RuntimeType.dotnet;
}

if (files.some((file) => path.extname(file) === "package.json")) {
if (files.includes("package.json")) {
return RuntimeType.node;
}

Expand Down

0 comments on commit bcda33c

Please sign in to comment.