mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
* Update linting configuration (eslint, prettier) * Fix lint issues following eslint prettier update * Change ESLint config to allow boolean coercion * Switch to default import name per docs * Fix suppression of error details * Update JSDoc comments * Update waiForFunctin to provide error details --------- Co-authored-by: Koy Zhuang <koy@ko8e24.top>
33 lines
841 B
JavaScript
33 lines
841 B
JavaScript
import * as process from 'node:process';
|
|
import { create } from 'browser-sync';
|
|
import { testConfig } from '../../server.configs.js';
|
|
|
|
const bsServer = create();
|
|
|
|
export async function startServer() {
|
|
// Wait for server to start
|
|
return new Promise(resolve => {
|
|
const settings = testConfig;
|
|
|
|
console.log('\n');
|
|
|
|
bsServer.init(settings, () => {
|
|
// Exit process if specified port is not available. BrowserSync
|
|
// auto-selects a new port if the specified port is unavailable. This is
|
|
// problematic for testing and CI/CD.
|
|
if (bsServer.getOption('port') !== settings.port) {
|
|
console.log(
|
|
`\nPort ${settings.port} not available. Exiting process.\n`,
|
|
);
|
|
process.exit(0);
|
|
}
|
|
|
|
resolve(bsServer);
|
|
});
|
|
});
|
|
}
|
|
|
|
export function stopServer() {
|
|
bsServer.exit();
|
|
}
|