2019-03-02 15:19:08 +00: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 14:44:46 +00:00
|
|
|
constructor(configPath: string, watchPaths: string[] = []) {
|
2019-03-02 15:19:08 +00:00
|
|
|
if (fs.existsSync('.suite')) {
|
2019-03-23 14:44:46 +00:00
|
|
|
this.runnerImpl = new AutheliaServerWithHotReload(configPath, watchPaths);
|
2019-03-02 15:19:08 +00:00
|
|
|
} else {
|
|
|
|
this.runnerImpl = new AutheliaServerFromDist(configPath, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async start() {
|
|
|
|
await this.runnerImpl.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
async stop() {
|
|
|
|
await this.runnerImpl.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default AutheliaServer;
|