Skip to content

Commit

Permalink
Spawn docker with a shell in windows for escaping json
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinMcNeil committed Oct 29, 2024
1 parent ad83d34 commit ca9241a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "labs-ai-tools-vscode",
"displayName": "Labs: AI Tools for VSCode",
"description": "Run & Debug AI Prompts with Dockerized tools",
"version": "0.1.8-ghu1",
"version": "0.1.8-ghu2",
"publisher": "docker",
"repository": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion src/commands/runPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ export const runPrompt: (secrets: vscode.SecretStorage, mode: PromptOption) => v
progress.report({ increment: 5, message: "Running..." });
const ranges: Record<string, vscode.Range> = {};
const getBaseFunctionRange = () => new vscode.Range(doc.lineCount, 0, doc.lineCount, 0);
await spawnPromptImage(promptOption.id, hostDir, Username || 'vscode-user', Password, process.platform, async (json) => {
const platformArg = process.platform === 'win32' ? 'windows' : process.platform === 'darwin' ? 'darwin' : 'linux';
await spawnPromptImage(promptOption.id, hostDir, Username || 'vscode-user', Password, platformArg, async (json) => {
extensionOutput.appendLine(JSON.stringify(json))

Check warning on line 177 in src/commands/runPrompt.ts

View workflow job for this annotation

GitHub Actions / test

Missing semicolon
switch (json.method) {
case 'functions':
Expand Down
8 changes: 7 additions & 1 deletion src/utils/promptRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export const writeKeyToVolume = async (key: string) => {
getJSONArgForPlatform({ files: [{ path: ".openai-api-key", content: key, executable: false }] })
];

extensionOutput.appendLine(JSON.stringify({"write-open-ai-key-to-volume": {
args1, args2
}}));

const child1 = spawn("docker", args1);

child1.stdout.on('data', (data) => {
Expand All @@ -124,7 +128,9 @@ export const writeKeyToVolume = async (key: string) => {
extensionOutput.appendLine(data.toString());
});

const child2 = spawn("docker", args2);
const child2 = spawn("docker", args2, {
shell: process.platform === 'win32'
});
child2.stdout.on('data', (data) => {
extensionOutput.appendLine(data.toString());
});
Expand Down

0 comments on commit ca9241a

Please sign in to comment.