How to use the browser-sync.has function in browser-sync

To help you get started, we’ve selected a few browser-sync examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github YuichiNukiyama / vscode-preview-server / src / server.ts View on Github external
public static start(rootPath: string, port: number, isSync: boolean, proxy = "", ui: UiOption = null) {
        // get browserSync instance.
        let bs: browserSync.BrowserSyncInstance;
        if (!browserSync.has("vscode-preview-server")) {
            bs = browserSync.create("vscode-preview-server");
        } else {
            bs = browserSync.get("vscode-preview-server");
        }

        let options: browserSync.Options;

        if (proxy === "") {
            options = {
                server: {
                    baseDir: rootPath,
                    directory: true
                },
                open: false,
                port: port,
                codeSync: isSync
github jdf2e / jdf / lib / server / browserSyncServer.js View on Github external
return new Promise((resolve, reject) => {
        let bsServer;
        if (bs.has(name)) {
            bsServer = bs.get(name);
        } else {
            bsServer = bs.create(name);
        }

        logger.verbose(`create or get server`);

        let openbrowser = options.autoOpen ? 'external' : false;

        bsServer.init({
            server: '',
            open: openbrowser,
            logPrefix: 'JDFX',
            port: options.port,
            socket: {
                path: '/jdf-bs/socket.io',
github YuichiNukiyama / vscode-preview-server / src / server.ts View on Github external
public static stop() {
        if (browserSync.has("vscode-preview-server")) {
            browserSync.get("vscode-preview-server").exit();
        }
    }
github YuichiNukiyama / vscode-preview-server / src / server.ts View on Github external
public static reload(fileName: string) {
        if (browserSync.has("vscode-preview-server")) {
            browserSync.get("vscode-preview-server").reload(fileName);
        }
    }
}
github fevrcoding / wok / build / gulp-tasks / watch.js View on Github external
return (done) => {

        const BrowserSync = require('browser-sync');

        const bs = BrowserSync.has(buildHash) ? BrowserSync.get(buildHash) : false;

        options.isWatching = true; //eslint-disable-line no-param-reassign

        const livereload = (d) => {
            bs.reload();
            d();
        };

        if (bs === false) {
            log.warn(cyan('BrowserSync instance not found. Assets live-reload will not be available.'));
        }

        list.forEach(({
            pattern, task, reload, unlink
        }) => {
            const tasks = [task];