File tree Expand file tree Collapse file tree
packages/opencode/test/tool Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -156,25 +156,30 @@ describe("tool.write", () => {
156156 await using tmp = await tmpdir ( )
157157 const filepath = path . join ( tmp . path , "sensitive.json" )
158158
159- await Instance . provide ( {
160- directory : tmp . path ,
161- fn : async ( ) => {
162- const write = await WriteTool . init ( )
163- await write . execute (
164- {
165- filePath : filepath ,
166- content : JSON . stringify ( { secret : "data" } ) ,
167- } ,
168- ctx ,
169- )
170-
171- // On Unix systems, check permissions
172- if ( process . platform !== "win32" ) {
173- const stats = await fs . stat ( filepath )
174- expect ( stats . mode & 0o777 ) . toBe ( 0o644 )
175- }
176- } ,
177- } )
159+ const prevUmask = process . umask ( 0o022 )
160+ try {
161+ await Instance . provide ( {
162+ directory : tmp . path ,
163+ fn : async ( ) => {
164+ const write = await WriteTool . init ( )
165+ await write . execute (
166+ {
167+ filePath : filepath ,
168+ content : JSON . stringify ( { secret : "data" } ) ,
169+ } ,
170+ ctx ,
171+ )
172+
173+ // On Unix systems, check permissions
174+ if ( process . platform !== "win32" ) {
175+ const stats = await fs . stat ( filepath )
176+ expect ( stats . mode & 0o777 ) . toBe ( 0o644 )
177+ }
178+ } ,
179+ } )
180+ } finally {
181+ process . umask ( prevUmask )
182+ }
178183 } )
179184 } )
180185
You can’t perform that action at this time.
0 commit comments