Skip to content

Commit

Permalink
Misc fixes for VS Code Extension (#5712)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 committed Apr 24, 2023
1 parent f2592d5 commit 2eb42bc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export class Command {
* @param options the command options object.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private async prepare(options: any): Promise<void> {
public async prepare(options: any): Promise<void> {
options = options || {};
options.project = getInheritedOption(options, "project");

Expand Down
2 changes: 1 addition & 1 deletion src/emulator/functionsEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ export class FunctionsEmulator implements EmulatorInstance {
path,
headers: req.headers,
},
res,
res as http.ServerResponse,
reqBody,
debugBundle
);
Expand Down
17 changes: 15 additions & 2 deletions src/frameworks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,22 @@ const DEFAULT_FIND_DEP_OPTIONS: FindDepOptions = {
export const WebFrameworks: Record<string, Framework> = Object.fromEntries(
readdirSync(__dirname)
.filter((path) => statSync(join(__dirname, path)).isDirectory())
.map((path) => [path, require(join(__dirname, path))])
.map((path) => {
// If not called by the CLI, (e.g., by the VS Code Extension)
// __dirname won't refer to this folder and these files won't be available.
// Instead it may find sibling folders that aren't modules, and this
// require will throw.
// Long term fix may be to bundle this instead of reading files at runtime
// but for now, this prevents crashing.
try {
return [path, require(join(__dirname, path))];
} catch (e) {
return [];
}
})
.filter(
([, obj]) => obj.name && obj.discover && obj.build && obj.type !== undefined && obj.support
([, obj]) =>
obj && obj.name && obj.discover && obj.build && obj.type !== undefined && obj.support
)
);

Expand Down
4 changes: 3 additions & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RC } from "./rc";

// Options come from command-line options and stored config values
// TODO: actually define all of this stuff in command.ts and import it from there.
export interface Options {
export interface BaseOptions {
cwd: string;
configPath: string;
only: string;
Expand All @@ -25,7 +25,9 @@ export interface Options {
debug: boolean;

rc: RC;
}

export interface Options extends BaseOptions {
// TODO(samstern): Remove this once options is better typed
[key: string]: unknown;
}

0 comments on commit 2eb42bc

Please sign in to comment.