fix: restore update command helpers (#1857)
Exported package-manager helpers used by openchamber update Added regression coverage for the update-available path
This commit is contained in:
@@ -483,7 +483,7 @@ export function detectPackageManagerDetails() {
|
||||
};
|
||||
}
|
||||
|
||||
function detectPackageManager() {
|
||||
export function detectPackageManager() {
|
||||
return detectPackageManagerDetails().packageManager;
|
||||
}
|
||||
|
||||
@@ -769,7 +769,7 @@ export async function checkForUpdates(options = {}) {
|
||||
/**
|
||||
* Execute the update (used by CLI)
|
||||
*/
|
||||
function executeUpdate(pm = detectPackageManager(), options = {}) {
|
||||
export function executeUpdate(pm = detectPackageManager(), options = {}) {
|
||||
const command = getUpdateCommand(pm);
|
||||
if (!options?.silent) {
|
||||
console.log(`Updating ${PACKAGE_NAME} using ${pm}...`);
|
||||
|
||||
@@ -6,7 +6,12 @@ vi.mock('node:child_process', () => ({
|
||||
spawnSync: vi.fn(() => ({ status: 0, stdout: '/usr/local/bin', stderr: '' })),
|
||||
}));
|
||||
|
||||
const { checkForUpdates, getCurrentVersion } = await import('./package-manager.js');
|
||||
const {
|
||||
checkForUpdates,
|
||||
detectPackageManager,
|
||||
executeUpdate,
|
||||
getCurrentVersion,
|
||||
} = await import('./package-manager.js');
|
||||
|
||||
/** Helper: create a fetch mock that routes by URL pattern */
|
||||
function createFetchMock() {
|
||||
@@ -251,3 +256,10 @@ describe('getCurrentVersion', () => {
|
||||
expect(getCurrentVersion()).toMatch(/^\d+\.\d+\.\d+|unknown$/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('CLI update exports', () => {
|
||||
it('exports package-manager helpers used by the update command', () => {
|
||||
expect(typeof detectPackageManager).toBe('function');
|
||||
expect(typeof executeUpdate).toBe('function');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user