Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/cli/commands/site/stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export async function runCommand(
}

if ( ! runningSites.length ) {
logger.reportSuccess( __( 'No sites are currently running' ) );
await killDaemonAndChildrenAndExitProcess( () => {
logger.reportSuccess( __( 'No sites are currently running' ) );
} );
return;
}

Expand Down
10 changes: 4 additions & 6 deletions apps/cli/commands/site/tests/stop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,17 +256,16 @@ describe( 'CLI: studio site stop --all', () => {
} );

describe( 'Success Cases', () => {
it( 'should handle empty sites list', async () => {
it( 'should kill daemon even with empty sites list', async () => {
vi.mocked( readAppdata ).mockResolvedValue( { sites: [], snapshots: [] } );

await runCommand( Mode.STOP_ALL_SITES, undefined, false );

expect( connect ).toHaveBeenCalled();
expect( killDaemonAndChildrenAndExitProcess ).not.toHaveBeenCalled();
expect( disconnect ).toHaveBeenCalled();
expect( killDaemonAndChildrenAndExitProcess ).toHaveBeenCalledTimes( 1 );
} );

it( 'should skip if no sites are running', async () => {
it( 'should kill daemon even if no sites are running', async () => {
vi.mocked( readAppdata ).mockResolvedValue( { sites: testSites, snapshots: [] } );

vi.mocked( isServerRunning ).mockResolvedValue( undefined );
Expand All @@ -275,9 +274,8 @@ describe( 'CLI: studio site stop --all', () => {

expect( connect ).toHaveBeenCalled();
expect( isServerRunning ).toHaveBeenCalledTimes( 3 );
expect( killDaemonAndChildrenAndExitProcess ).not.toHaveBeenCalled();
expect( killDaemonAndChildrenAndExitProcess ).toHaveBeenCalledTimes( 1 );
expect( clearSiteLatestCliPid ).not.toHaveBeenCalled();
expect( disconnect ).toHaveBeenCalled();
} );

it( 'should handle single site', async () => {
Expand Down
10 changes: 0 additions & 10 deletions package-lock.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change required?

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading