Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
let action;
try {
if (!patternlab.isBusy) {
if (_data.file.indexOf('css') > -1 || _data.action === 'refresh') {
action = 'refreshed CSS';
liveServer.refreshCSS();
} else {
action = 'reloaded';
liveServer.reload();
}
resolve(`Server ${action} successfully`);
}
} catch (e) {
reject(`Server reload or refresh failed: ${e}`);
}
});
},
return new Promise((resolve, reject) => {
let action;
try {
if (!patternlab.isBusy) {
if (_data.file.indexOf('css') > -1 || _data.action === 'refresh') {
action = 'refreshed CSS';
liveServer.refreshCSS();
} else {
action = 'reloaded';
liveServer.reload();
}
resolve(`Server ${action} successfully`);
}
} catch (e) {
reject(`Server reload or refresh failed: ${e}`);
}
});
},
setTimeout(() => {
try {
liveServer.start(liveServerConfig);
resolveMsg = `Pattern Lab is being served from http://127.0.0.1:${liveServerConfig.port}`;
logger.info(resolveMsg);
} catch (e) {
const err = `Pattern Lab serve failed to start: ${e}`;
logger.error(`Pattern Lab serve failed to start: ${e}`);
reject(err);
}
setupEventWatchers();
serverReady = true;
resolve(resolveMsg);
}, liveServerConfig.wait);
});