@@ -1800,68 +1800,3 @@ describe("OPENCODE_DISABLE_PROJECT_CONFIG", () => {
18001800 }
18011801 } )
18021802} )
1803-
1804- // OPENCODE_CONFIG_CONTENT should support {env:} and {file:} token substitution
1805- // just like file-based config sources do.
1806- describe ( "OPENCODE_CONFIG_CONTENT token substitution" , ( ) => {
1807- test ( "substitutes {env:} tokens in OPENCODE_CONFIG_CONTENT" , async ( ) => {
1808- const originalEnv = process . env [ "OPENCODE_CONFIG_CONTENT" ]
1809- const originalTestVar = process . env [ "TEST_CONFIG_VAR" ]
1810- process . env [ "TEST_CONFIG_VAR" ] = "test_api_key_12345"
1811- process . env [ "OPENCODE_CONFIG_CONTENT" ] = JSON . stringify ( {
1812- $schema : "https://opencode.ai/config.json" ,
1813- theme : "{env:TEST_CONFIG_VAR}" ,
1814- } )
1815-
1816- try {
1817- await using tmp = await tmpdir ( )
1818- await Instance . provide ( {
1819- directory : tmp . path ,
1820- fn : async ( ) => {
1821- const config = await Config . get ( )
1822- expect ( config . theme ) . toBe ( "test_api_key_12345" )
1823- } ,
1824- } )
1825- } finally {
1826- if ( originalEnv !== undefined ) {
1827- process . env [ "OPENCODE_CONFIG_CONTENT" ] = originalEnv
1828- } else {
1829- delete process . env [ "OPENCODE_CONFIG_CONTENT" ]
1830- }
1831- if ( originalTestVar !== undefined ) {
1832- process . env [ "TEST_CONFIG_VAR" ] = originalTestVar
1833- } else {
1834- delete process . env [ "TEST_CONFIG_VAR" ]
1835- }
1836- }
1837- } )
1838-
1839- test ( "substitutes {file:} tokens in OPENCODE_CONFIG_CONTENT" , async ( ) => {
1840- const originalEnv = process . env [ "OPENCODE_CONFIG_CONTENT" ]
1841-
1842- try {
1843- await using tmp = await tmpdir ( {
1844- init : async ( dir ) => {
1845- await Bun . write ( path . join ( dir , "api_key.txt" ) , "secret_key_from_file" )
1846- process . env [ "OPENCODE_CONFIG_CONTENT" ] = JSON . stringify ( {
1847- $schema : "https://opencode.ai/config.json" ,
1848- theme : "{file:./api_key.txt}" ,
1849- } )
1850- } ,
1851- } )
1852- await Instance . provide ( {
1853- directory : tmp . path ,
1854- fn : async ( ) => {
1855- const config = await Config . get ( )
1856- expect ( config . theme ) . toBe ( "secret_key_from_file" )
1857- } ,
1858- } )
1859- } finally {
1860- if ( originalEnv !== undefined ) {
1861- process . env [ "OPENCODE_CONFIG_CONTENT" ] = originalEnv
1862- } else {
1863- delete process . env [ "OPENCODE_CONFIG_CONTENT" ]
1864- }
1865- }
1866- } )
1867- } )
0 commit comments