Skip to content

Commit 63a6cec

Browse files
authored
Merge pull request #59 from ServerlessLife/58-fix-when-first-stack-not-serverless-stack
fix: Fix an issue with cdkstack not working when first stack did not contain ServerlessSpyWsUrl
2 parents 8d82625 + 45d6a14 commit 63a6cec

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

cli/cli.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ async function run() {
8181
let wsUrl: string | undefined;
8282
if (options.ws) {
8383
wsUrl = options.ws;
84-
} else {
85-
if (cdkOutput && cdkOutput[Object.keys(cdkOutput)[0]]) {
84+
} else if (cdkOutput) {
85+
if (cdkOutput[options.cdkstack]) {
86+
wsUrl = cdkOutput[options.cdkstack].ServerlessSpyWsUrl;
87+
} else if (cdkOutput[Object.keys(cdkOutput)[0]]) {
8688
wsUrl = cdkOutput[Object.keys(cdkOutput)[0]].ServerlessSpyWsUrl;
8789
}
8890
}
@@ -174,13 +176,7 @@ async function run() {
174176

175177
if (request.url === '/stackList') {
176178
response.writeHead(200, { 'Content-Type': 'application/json' });
177-
178-
const stackListAvailable: string[] | undefined =
179-
options.cdkstack && stackList?.includes(options.cdkstack)
180-
? [options.cdkstack]
181-
: stackList;
182-
183-
response.end(JSON.stringify(stackListAvailable), 'utf-8');
179+
response.end(JSON.stringify(stackList), 'utf-8');
184180
} else if (request.url?.match('^/wsUrl')) {
185181
response.writeHead(200, { 'Content-Type': 'text/html' });
186182
response.end(`ws:localhost:${options.wsport}`, 'utf-8');
@@ -212,7 +208,7 @@ async function run() {
212208
.listen(options.port);
213209

214210
console.log(
215-
`ServerlessSoy console runing at http://localhost:${options.port}`
211+
`ServerlessSpy console runing at http://localhost:${options.port}`
216212
);
217213
if (options.open) {
218214
await opener(`http://localhost:${options.port}`);

0 commit comments

Comments
 (0)