5
5
import { v1 } from "@docker/extension-api-client-types" ;
6
6
import { ExecResult } from "@docker/extension-api-client-types/dist/v0" ;
7
7
import { encode } from "js-base64" ;
8
-
9
8
import { BUSYBOX } from "../Constants" ;
10
9
11
10
export const tryRunImageSync = async (
12
11
client : v1 . DockerDesktopClient ,
13
12
args : string [ ] ,
14
13
ignoreError = false
15
14
) => {
16
- const showError = ignoreError ? ( ) => { } : client . desktopUI . toast . error ;
15
+ const showError = ignoreError ? ( ) => { } : client . desktopUI . toast . error ;
17
16
try {
18
17
const result = await client . docker . cli . exec ( "run" , args ) ;
19
- if ( result . code !== undefined && result . code != 0 && result . stderr ) {
18
+ if ( result . stderr && result . stderr . includes ( "shell operators are not allowed" ) ) {
19
+ // This shouldn't happen: it means we have our escaping wrong.
20
+ // And there's no way to check that failure other than by looking at stderr's content...
20
21
showError ( result . stderr ) ;
21
22
}
22
23
return result . stdout || "" ;
@@ -82,7 +83,7 @@ export const writeToPromptsVolume = async (
82
83
BUSYBOX ,
83
84
"/bin/sh" ,
84
85
"-c" ,
85
- `\\" echo ${ encode ( content ) } | base64 -d > ${ filename } \\" ` ,
86
+ `' echo ${ encode ( content ) } | base64 -d > ${ filename } ' ` ,
86
87
] ) ;
87
88
} ;
88
89
@@ -99,6 +100,6 @@ export const writeToMount = async (
99
100
BUSYBOX ,
100
101
"/bin/sh" ,
101
102
"-c" ,
102
- `\\" echo ${ encode ( content ) } | base64 -d > ${ filename } \\" ` ,
103
+ `' echo ${ encode ( content ) } | base64 -d > ${ filename } ' ` ,
103
104
] ) ;
104
105
} ;
0 commit comments