@@ -36,40 +36,44 @@ test("readClipboardImage returns null when no clipboard helpers are installed",
3636 assert . equal ( result , null ) ;
3737} ) ;
3838
39- test ( "readClipboardImage uses osascript fallback on macOS when pngpaste is missing" , async ( ) => {
40- const binDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "deepcode-clipboard-test-bin-" ) ) ;
41- try {
42- fs . writeFileSync ( path . join ( binDir , "pngpaste" ) , "#!/bin/sh\nexit 1\n" , { mode : 0o755 } ) ;
43- fs . writeFileSync (
44- path . join ( binDir , "osascript" ) ,
45- [
46- "#!/bin/sh" ,
47- 'for arg in "$@"; do' ,
48- ' case "$arg" in' ,
49- " *'open for access POSIX file " + '"' + "'*)" ,
50- ' path_part=${arg#*POSIX file \\"}' ,
51- ' out_path=${path_part%%\\"*}' ,
52- ' printf fakepng > "$out_path"' ,
53- " exit 0" ,
54- " ;;" ,
55- " esac" ,
56- "done" ,
57- "exit 1" ,
58- "" ,
59- ] . join ( "\n" ) ,
60- { mode : 0o755 }
61- ) ;
39+ test (
40+ "readClipboardImage uses osascript fallback on macOS when pngpaste is missing" ,
41+ { skip : process . platform === "win32" } ,
42+ async ( ) => {
43+ const binDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "deepcode-clipboard-test-bin-" ) ) ;
44+ try {
45+ fs . writeFileSync ( path . join ( binDir , "pngpaste" ) , "#!/bin/sh\nexit 1\n" , { mode : 0o755 } ) ;
46+ fs . writeFileSync (
47+ path . join ( binDir , "osascript" ) ,
48+ [
49+ "#!/bin/sh" ,
50+ 'for arg in "$@"; do' ,
51+ ' case "$arg" in' ,
52+ " *'open for access POSIX file " + '"' + "'*)" ,
53+ ' path_part=${arg#*POSIX file \\"}' ,
54+ ' out_path=${path_part%%\\"*}' ,
55+ ' printf fakepng > "$out_path"' ,
56+ " exit 0" ,
57+ " ;;" ,
58+ " esac" ,
59+ "done" ,
60+ "exit 1" ,
61+ "" ,
62+ ] . join ( "\n" ) ,
63+ { mode : 0o755 }
64+ ) ;
6265
63- const moduleUrl = new URL ( `../ui/clipboard.ts?t=${ Date . now ( ) } ` , import . meta. url ) . href ;
64- const { readClipboardImage } = ( await import ( moduleUrl ) ) as ClipboardModule ;
66+ const moduleUrl = new URL ( `../ui/clipboard.ts?t=${ Date . now ( ) } ` , import . meta. url ) . href ;
67+ const { readClipboardImage } = ( await import ( moduleUrl ) ) as ClipboardModule ;
6568
66- process . env . PATH = binDir ;
67- const result = withPlatform ( "darwin" , ( ) => readClipboardImage ( ) ) ;
68- assert . equal ( result ?. mimeType , "image/png" ) ;
69- assert . equal ( result ?. dataUrl , `data:image/png;base64,${ Buffer . from ( "fakepng" ) . toString ( "base64" ) } ` ) ;
70- } finally {
71- process . env . PATH = ORIGINAL_PATH ;
72- Object . defineProperty ( process , "platform" , { value : ORIGINAL_PLATFORM } ) ;
73- fs . rmSync ( binDir , { recursive : true , force : true } ) ;
69+ process . env . PATH = binDir ;
70+ const result = withPlatform ( "darwin" , ( ) => readClipboardImage ( ) ) ;
71+ assert . equal ( result ?. mimeType , "image/png" ) ;
72+ assert . equal ( result ?. dataUrl , `data:image/png;base64,${ Buffer . from ( "fakepng" ) . toString ( "base64" ) } ` ) ;
73+ } finally {
74+ process . env . PATH = ORIGINAL_PATH ;
75+ Object . defineProperty ( process , "platform" , { value : ORIGINAL_PLATFORM } ) ;
76+ fs . rmSync ( binDir , { recursive : true , force : true } ) ;
77+ }
7478 }
75- } ) ;
79+ ) ;
0 commit comments