add .reload()
This commit is contained in:
parent
6e079e38c3
commit
d6a7fd6c8c
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -28,4 +28,5 @@ export declare class Smartbrowser {
|
|||||||
* stops the smartbrowser instance
|
* stops the smartbrowser instance
|
||||||
*/
|
*/
|
||||||
stop(): Promise<void>;
|
stop(): Promise<void>;
|
||||||
|
reload(): Promise<void>;
|
||||||
}
|
}
|
||||||
|
56
dist/index.js
vendored
56
dist/index.js
vendored
@ -1,4 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const plugins = require("./smartbrowser.plugins");
|
const plugins = require("./smartbrowser.plugins");
|
||||||
/**
|
/**
|
||||||
@ -18,32 +26,38 @@ class Smartbrowser {
|
|||||||
* starts the server and returns the browserSync instance in a resolved Promise
|
* starts the server and returns the browserSync instance in a resolved Promise
|
||||||
*/
|
*/
|
||||||
start() {
|
start() {
|
||||||
let done = plugins.smartq.defer();
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (this.bsStatus === 'idle') {
|
let done = plugins.smartq.defer();
|
||||||
this.bsStatus = 'starting';
|
if (this.bsStatus === 'idle') {
|
||||||
let localDone = plugins.smartq.defer();
|
this.bsStatus = 'starting';
|
||||||
this.bsStarted = localDone.promise;
|
let localDone = plugins.smartq.defer();
|
||||||
this.bsInstance.init(this.bsConfig, () => {
|
this.bsStarted = localDone.promise;
|
||||||
this.bsStatus = 'running';
|
this.bsInstance.init(this.bsConfig, () => {
|
||||||
localDone.resolve();
|
this.bsStatus = 'running';
|
||||||
done.resolve(this.bsInstance);
|
localDone.resolve();
|
||||||
});
|
done.resolve(this.bsInstance);
|
||||||
}
|
});
|
||||||
else {
|
}
|
||||||
this.bsStarted.then(() => { done.resolve(this.bsInstance); });
|
else {
|
||||||
}
|
this.bsStarted.then(() => { done.resolve(this.bsInstance); });
|
||||||
return done.promise;
|
}
|
||||||
|
return yield done.promise;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* stops the smartbrowser instance
|
* stops the smartbrowser instance
|
||||||
*/
|
*/
|
||||||
stop() {
|
stop() {
|
||||||
let done = plugins.smartq.defer();
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
this.bsInstance.exit();
|
this.bsInstance.exit();
|
||||||
this.bsStatus = 'idle';
|
this.bsStatus = 'idle';
|
||||||
done.resolve();
|
});
|
||||||
return done.promise;
|
}
|
||||||
|
reload() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
this.bsInstance.reload();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Smartbrowser = Smartbrowser;
|
exports.Smartbrowser = Smartbrowser;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLGtEQUFpRDtBQWdCakQ7O0dBRUc7QUFDSDtJQU9FLFlBQWEsVUFBZ0M7UUFON0MsZUFBVSxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsTUFBTSxFQUFFLENBQUE7UUFDekMsYUFBUSxHQUFnQztZQUN0QyxNQUFNLEVBQUUsRUFBRTtTQUNY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FBTSxFQUFFLENBQUE7UUFDMUIsQ0FBQztLQUFBO0NBQ0Y7QUEzQ0Qsb0NBMkNDIn0=
|
13
ts/index.ts
13
ts/index.ts
@ -32,7 +32,7 @@ export class Smartbrowser {
|
|||||||
/**
|
/**
|
||||||
* starts the server and returns the browserSync instance in a resolved Promise
|
* starts the server and returns the browserSync instance in a resolved Promise
|
||||||
*/
|
*/
|
||||||
start (): Promise<plugins.browserSync.BrowserSyncInstance> {
|
async start (): Promise<plugins.browserSync.BrowserSyncInstance> {
|
||||||
let done = plugins.smartq.defer<plugins.browserSync.BrowserSyncInstance>()
|
let done = plugins.smartq.defer<plugins.browserSync.BrowserSyncInstance>()
|
||||||
if (this.bsStatus === 'idle') {
|
if (this.bsStatus === 'idle') {
|
||||||
this.bsStatus = 'starting'
|
this.bsStatus = 'starting'
|
||||||
@ -46,17 +46,18 @@ export class Smartbrowser {
|
|||||||
} else {
|
} else {
|
||||||
this.bsStarted.then(() => { done.resolve(this.bsInstance) })
|
this.bsStarted.then(() => { done.resolve(this.bsInstance) })
|
||||||
}
|
}
|
||||||
return done.promise
|
return await done.promise
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* stops the smartbrowser instance
|
* stops the smartbrowser instance
|
||||||
*/
|
*/
|
||||||
stop (): Promise<void> {
|
async stop (): Promise<void> {
|
||||||
let done = plugins.smartq.defer<void>()
|
|
||||||
this.bsInstance.exit()
|
this.bsInstance.exit()
|
||||||
this.bsStatus = 'idle'
|
this.bsStatus = 'idle'
|
||||||
done.resolve()
|
}
|
||||||
return done.promise
|
|
||||||
|
async reload (): Promise<void> {
|
||||||
|
this.bsInstance.reload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user