Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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',
public static stop() {
if (browserSync.has("vscode-preview-server")) {
browserSync.get("vscode-preview-server").exit();
}
}
public static reload(fileName: string) {
if (browserSync.has("vscode-preview-server")) {
browserSync.get("vscode-preview-server").reload(fileName);
}
}
}
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];