Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions extensions/localPublish/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { DialogSetting, PublishPlugin, IExtensionRegistration } from '@botframew

import killPort from 'kill-port';
import map from 'lodash/map';
import range from 'lodash/range';
import * as tcpPortUsed from 'tcp-port-used';

const stat = promisify(fs.stat);
Expand Down Expand Up @@ -52,6 +51,17 @@ const isLocalhostUrl = (matchUrl: string) => {
const isSkillHostUpdateRequired = (skillHostEndpoint?: string) => {
return !skillHostEndpoint || isLocalhostUrl(skillHostEndpoint);
};

const stringifyError = (error: any): string => {
if (error instanceof Error) {
return `${error.name} - ${error.message}`;
} else if (typeof error === 'object') {
return JSON.stringify(error, Object.getOwnPropertyNames(error));
} else {
return error;
Comment thread
VanyLaw marked this conversation as resolved.
Outdated
}
}

class LocalPublisher implements PublishPlugin<PublishConfig> {
public name = 'localpublish';
public description = 'Publish bot to local runtime';
Expand Down Expand Up @@ -114,7 +124,7 @@ class LocalPublisher implements PublishPlugin<PublishConfig> {
this.setBotStatus(botId, {
status: 500,
result: {
message: error.message,
message: stringifyError(error),
},
});
}
Expand Down Expand Up @@ -149,7 +159,7 @@ class LocalPublisher implements PublishPlugin<PublishConfig> {
return {
status: 500,
result: {
message: error,
message: stringifyError(error),
},
};
}
Expand Down Expand Up @@ -279,7 +289,7 @@ class LocalPublisher implements PublishPlugin<PublishConfig> {
} catch (error) {
// delete the folder to make sure build again.
await removeDirAndFiles(this.getBotDir(botId));
throw new Error(error.toString());
throw error;
}
};

Expand Down Expand Up @@ -324,12 +334,11 @@ class LocalPublisher implements PublishPlugin<PublishConfig> {
// start the bot process
await this.startBot(botId, port, settings, project);
} catch (error) {
console.error('Error in startbot: ', error);
await this.stopBot(botId);
this.setBotStatus(botId, {
status: 500,
result: {
message: error,
message: stringifyError(error),
},
});
}
Expand Down