2019-03-02 22:19:08 +07:00
|
|
|
import fs from 'fs';
|
|
|
|
import AutheliaServerWithHotReload from "./AutheliaServerWithHotReload";
|
|
|
|
import AutheliaServerInterface from './AutheliaServerInterface';
|
|
|
|
import AutheliaServerFromDist from './AutheliaServerFromDist';
|
|
|
|
|
|
|
|
class AutheliaServer implements AutheliaServerInterface {
|
|
|
|
private runnerImpl: AutheliaServerInterface;
|
|
|
|
|
2019-03-23 21:44:46 +07:00
|
|
|
constructor(configPath: string, watchPaths: string[] = []) {
|
2019-03-02 22:19:08 +07:00
|
|
|
if (fs.existsSync('.suite')) {
|
2019-03-23 21:44:46 +07:00
|
|
|
this.runnerImpl = new AutheliaServerWithHotReload(configPath, watchPaths);
|
2019-03-02 22:19:08 +07:00
|
|
|
} else {
|
|
|
|
this.runnerImpl = new AutheliaServerFromDist(configPath, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async start() {
|
|
|
|
await this.runnerImpl.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
async stop() {
|
|
|
|
await this.runnerImpl.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default AutheliaServer;
|