Skip to content

Commit d014fbd

Browse files
committed
fix: --api-devserver-url not working if --api-location not set (#523, #579)
1 parent 7ecbae2 commit d014fbd

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/cli/commands/start.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ export default function registerCommand(program: Command) {
3535
.option("-a, --app-location <path>", "the folder containing the source code of the front-end application", DEFAULT_CONFIG.appLocation)
3636
.option("-i, --api-location <path>", "the folder containing the source code of the API application", DEFAULT_CONFIG.apiLocation)
3737
.option("-O, --output-location <path>", "the folder containing the built source of the front-end application", DEFAULT_CONFIG.outputLocation)
38-
.option("-D, --app-devserver-url <url>", "connect to the app dev server at this URL instead of using output location", DEFAULT_CONFIG.appDevserverUrl)
39-
.option("-is, --api-devserver-url <url>", "connect to the api server at this URL instead of using output location", DEFAULT_CONFIG.apiDevserverUrl)
38+
.option(
39+
"-D, --app-devserver-url <url>",
40+
"connect to the app dev server at this URL instead of using output location",
41+
DEFAULT_CONFIG.appDevserverUrl
42+
)
43+
.option("-is, --api-devserver-url <url>", "connect to the api server at this URL instead of using api location", DEFAULT_CONFIG.apiDevserverUrl)
4044
.option<number>("-j, --api-port <apiPort>", "the API server port passed to `func start`", parsePort, DEFAULT_CONFIG.apiPort)
4145
.option("-q, --host <host>", "the host address to use for the CLI dev server", DEFAULT_CONFIG.host)
4246
.option<number>("-p, --port <port>", "the port value to use for the CLI dev server", parsePort, DEFAULT_CONFIG.port)
@@ -107,7 +111,7 @@ Use a custom command to run framework development server at startup
107111
swa start http://localhost:3000 --run-build "npm start"
108112
109113
Connect both front-end and the API to running development server
110-
swa start http://localhost:3000 --api-location http://localhost:7071
114+
swa start http://localhost:3000 --api-devserver-url http://localhost:7071
111115
`
112116
);
113117
}
@@ -183,17 +187,16 @@ export async function start(options: SWACLIConfig) {
183187
logger.silly(` ${outputLocation}`);
184188
}
185189

186-
if (apiLocation) {
190+
if (apiDevserverUrl) {
191+
// TODO: properly refactor this after GA to send apiDevserverUrl to the server
192+
useApiDevServer = apiDevserverUrl;
193+
apiLocation = apiDevserverUrl;
194+
} else if (apiLocation) {
187195
// resolves to the absolute path of the apiLocation
188196
let resolvedApiLocation = path.resolve(apiLocation);
189197

190-
if (apiDevserverUrl) {
191-
// TODO: properly refactor this after GA to send apiDevserverUrl to the server
192-
useApiDevServer = apiDevserverUrl;
193-
apiLocation = apiDevserverUrl;
194-
}
195198
// make sure api folder exists
196-
else if (fs.existsSync(resolvedApiLocation)) {
199+
if (fs.existsSync(resolvedApiLocation)) {
197200
apiLocation = resolvedApiLocation;
198201
} else {
199202
logger.info(`Skipping API because folder "${resolvedApiLocation}" is missing`, "swa");

0 commit comments

Comments
 (0)