Skip to content

Commit 52a37a9

Browse files
committed
refactor args
1 parent 086ec55 commit 52a37a9

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

src/commands.ts

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -620,20 +620,20 @@ export class Commands {
620620
*
621621
* Throw if not logged into a deployment.
622622
*/
623-
public async openDevContainer(...args: string[]): Promise<void> {
623+
public async openDevContainer(
624+
workspaceOwner: string,
625+
workspaceName: string,
626+
workspaceAgent: string,
627+
devContainerName: string,
628+
devContainerFolder: string,
629+
localWorkspaceFolder: string = "",
630+
localConfigFile: string = "",
631+
): Promise<void> {
624632
const baseUrl = this.restClient.getAxiosInstance().defaults.baseURL;
625633
if (!baseUrl) {
626634
throw new Error("You are not logged in");
627635
}
628636

629-
const workspaceOwner = args[0] as string;
630-
const workspaceName = args[1] as string;
631-
const workspaceAgent = args[2] as string;
632-
const devContainerName = args[3] as string;
633-
const devContainerFolder = args[4] as string;
634-
const localWorkspaceFolder = args[5] as string | undefined;
635-
const localConfigFile = args[6] as string | undefined;
636-
637637
await openDevContainer(
638638
baseUrl,
639639
workspaceOwner,
@@ -755,8 +755,8 @@ async function openDevContainer(
755755
workspaceAgent: string,
756756
devContainerName: string,
757757
devContainerFolder: string,
758-
localWorkspaceFolder: string | undefined,
759-
localConfigFile: string | undefined,
758+
localWorkspaceFolder: string = "",
759+
localConfigFile: string = "",
760760
) {
761761
const remoteAuthority = toRemoteAuthority(
762762
baseUrl,
@@ -765,20 +765,18 @@ async function openDevContainer(
765765
workspaceAgent,
766766
);
767767

768-
if (!localWorkspaceFolder) {
769-
localConfigFile = undefined;
770-
}
771-
let configFile;
772-
if (localConfigFile) {
773-
configFile = {
774-
path: localConfigFile,
775-
scheme: "vscode-fileHost",
776-
};
777-
}
768+
const hostPath = localWorkspaceFolder ? localWorkspaceFolder : undefined;
769+
const configFile =
770+
hostPath && localConfigFile
771+
? {
772+
path: localConfigFile,
773+
scheme: "vscode-fileHost",
774+
}
775+
: undefined;
778776
const devContainer = Buffer.from(
779777
JSON.stringify({
780778
containerName: devContainerName,
781-
hostPath: localWorkspaceFolder,
779+
hostPath,
782780
configFile,
783781
localDocker: false,
784782
}),

0 commit comments

Comments
 (0)