Skip to content

Commit

Permalink
fix: small runtime tweaks (#3519) (#3522)
Browse files Browse the repository at this point in the history
* fix: azure logs issues

Can't log after response is written for some reason.

* fix: watch files in dev only

* fix: load appsettings files based on NODE_ENV

Roughly maps to behavior added via microsoft/botbuilder-dotnet#5421
  • Loading branch information
joshgummersall authored Apr 5, 2021
1 parent f97b675 commit 5cc26c8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function makeTriggers(

return {
messageTrigger: async (context: Context, req: HttpRequest) => {
context.log('Messages endpoint triggerd.');
context.log('Messages endpoint triggered.');

try {
const { adapter, bot } = await instances();
Expand All @@ -57,8 +57,6 @@ export function makeTriggers(
context.log.error(err);
throw err;
}

context.log('Done.');
},

skillsTrigger: async function (context: Context, req: HttpRequest) {
Expand Down Expand Up @@ -86,8 +84,6 @@ export function makeTriggers(
context.log.error(err);
throw err;
}

context.log('Done.');
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ export class ConfigurationResourceExporer extends ResourceExplorer {
const applicationRoot = configuration.string(['applicationRoot']);
ok(applicationRoot);

this.folderResourceProvider = new FolderResourceProvider(this, applicationRoot, true, true);
this.folderResourceProvider = new FolderResourceProvider(
this,
applicationRoot,
true,
configuration.string(['NODE_ENV']) === 'dev' // watch in dev only!
);

this.addResourceProvider(this.folderResourceProvider);
}
}
15 changes: 10 additions & 5 deletions libraries/botbuilder-dialogs-adaptive-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,16 @@ export async function getRuntimeServices(
// Resolve configuration
let configuration: Configuration;
if (typeof configurationOrSettingsDirectory === 'string') {
configuration = new Configuration()
.argv()
.env()
.file(path.join(configurationOrSettingsDirectory, 'appsettings.Development.json'))
.file(path.join(configurationOrSettingsDirectory, 'appsettings.json'));
configuration = new Configuration().argv().env();

const files = ['appsettings.json'];

const { NODE_ENV: nodeEnv } = process.env;
if (nodeEnv) {
files.unshift(`appsettings.${nodeEnv}.json`);
}

files.forEach((file) => configuration.file(path.join(configurationOrSettingsDirectory, file)));
} else {
configuration = configurationOrSettingsDirectory;
}
Expand Down

0 comments on commit 5cc26c8

Please sign in to comment.