@@ -68,6 +68,37 @@ describe('Dev Containers CLI', function () {
6868
6969 await shellExec ( `docker rm -f ${ upResponse . containerId } ` ) ;
7070 } ) ;
71+
72+ it ( 'run-user-commands should run with default workspace folder (current directory)' , async ( ) => {
73+ const testFolder = `${ __dirname } /configs/image` ;
74+ const absoluteTmpPath = path . resolve ( __dirname , 'tmp' ) ;
75+ const absoluteCli = `npx --prefix ${ absoluteTmpPath } devcontainer` ;
76+
77+ // First, ensure container is up
78+ const upRes = await shellExec ( `${ cli } up --workspace-folder ${ testFolder } --skip-post-create` ) ;
79+ const upResponse = JSON . parse ( upRes . stdout ) ;
80+ assert . strictEqual ( upResponse . outcome , 'success' ) ;
81+ const containerId = upResponse . containerId ;
82+
83+ const originalCwd = process . cwd ( ) ;
84+ try {
85+ // Change to workspace folder
86+ process . chdir ( testFolder ) ;
87+
88+ // Run user commands without --workspace-folder should use current directory as default
89+ const runRes = await shellExec ( `${ absoluteCli } run-user-commands` ) ;
90+ const runResponse = JSON . parse ( runRes . stdout ) ;
91+ assert . strictEqual ( runResponse . outcome , 'success' ) ;
92+
93+ // Verify that the postCreateCommand was executed
94+ await shellExec ( `docker exec ${ containerId } test -f /postCreateCommand.txt` ) ;
95+ } finally {
96+ // Restore original directory
97+ process . chdir ( originalCwd ) ;
98+ // Clean up container
99+ await shellExec ( `docker rm -f ${ containerId } ` ) ;
100+ }
101+ } ) ;
71102 } ) ;
72103
73104 describe ( 'Command read-configuration' , ( ) => {
0 commit comments