diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index adfc1502b..c64bc615f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,11 +29,21 @@ jobs: - run: npm run lint:server - run: npm run test:e2e + # remove dev deps + - run: npm clean-install --production + # test hb-service - run: node dist/bin/hb-service.js -v - if: runner.os == 'Linux' - run: sudo node dist/bin/hb-service.js install --user homebridge + run: | + sudo node dist/bin/hb-service.js install --user homebridge + sleep 15 - if: runner.os == 'macOS' - run: sudo node dist/bin/hb-service.js install + run: | + sudo node dist/bin/hb-service.js install + sleep 15 - if: runner.os == 'Windows' - run: node dist/bin/hb-service.js install \ No newline at end of file + run: | + node dist/bin/hb-service.js install + Start-Sleep -s 15 + - run: node dist/bin/hb-service.js status --port 8581 \ No newline at end of file diff --git a/src/bin/hb-service.ts b/src/bin/hb-service.ts index 8f19668c9..30de6d843 100644 --- a/src/bin/hb-service.ts +++ b/src/bin/hb-service.ts @@ -24,7 +24,7 @@ import { LinuxInstaller } from './platforms/linux'; import { DarwinInstaller } from './platforms/darwin'; export class HomebridgeServiceHelper { - public action: 'install' | 'uninstall' | 'start' | 'stop' | 'restart' | 'rebuild' | 'run' | 'logs' | 'update-node' | 'before-start'; + public action: 'install' | 'uninstall' | 'start' | 'stop' | 'restart' | 'rebuild' | 'run' | 'logs' | 'update-node' | 'before-start' | 'status'; public selfPath = __filename; public serviceName = 'Homebridge'; public storagePath; @@ -144,6 +144,10 @@ export class HomebridgeServiceHelper { process.exit(0); break; } + case 'status': { + this.checkStatus(); + break; + } default: { commander.outputHelp(); @@ -1102,6 +1106,26 @@ export class HomebridgeServiceHelper { } } + /** + * Check the current status of the Homebridge UI by calling it's API + */ + private async checkStatus() { + this.logger(`Testing hb-service is running on port ${this.uiPort}...`); + + try { + const res = await axios.get(`http://localhost:${this.uiPort}/api`); + if (res.data === 'Hello World!') { + this.logger('Homebridge UI Running', 'succeed'); + } else { + this.logger('Unexpected Response', 'fail'); + process.exit(1); + } + } catch (e) { + this.logger('Homebridge UI Not Running', 'fail'); + process.exit(1); + } + } + } function bootstrap() {