Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
generateBundle () {
if (!running) {
running = true
// Log which url to visit
const url = (options.https ? 'https' : 'http') + '://' + (options.host || 'localhost') + ':' + options.port
options.contentBase.forEach(base => {
console.log(green(url) + ' -> ' + resolve(base))
})
// Open browser
if (options.open) {
if (/https?:\/\/.+/.test(options.openPage)) {
opener(options.openPage)
} else {
opener(url + options.openPage)
}
}
}
}
}
generateBundle() {
if (!running) {
running = true;
// Log which url to visit
const url = 'http://' + options.host + ':' + options.port;
options.contentBase.forEach(base => {
console.log(green(url) + ' -> ' + resolve(base));
});
// Open browser
if (options.open) {
opener(url + options.openPage);
}
console.log(chalk.green('Compiled successfully.'));
}
}
};
);
}
break;
case 'homepage':
// Ask user about this module again
modulesToUpdate.unshift(outdatedModule);
if (homepage === undefined) {
console.log('Trying to find homepage URL...');
homepage = outdatedModule.homepage = getModuleHomepage(await getModuleInfo(name));
}
if (homepage) {
console.log(`Opening ${strong(homepage)}...`);
opener(homepage);
} else {
console.log(`Sorry, there is no info about homepage URL in the ${strong(name)}'s package.json`);
}
break;
case 'ignore': {
const {versions, reason} = await askIgnoreFields(latestVersions[name]);
config.ignore[name] = {versions, reason};
break;
}
case 'finish':
isUpdateFinished = true;
break;
case true:
});
switch (answer) {
case 'changelog':
// Ask user about this module again
modulesToUpdate.unshift(outdatedModule);
if (changelogUrl === undefined) {
console.log('Trying to find changelog URL...');
changelogUrl =
outdatedModule.changelogUrl = await findModuleChangelogUrl(name);
}
if (changelogUrl) {
console.log(`Opening ${strong(changelogUrl)}...`);
opener(changelogUrl);
} else {
console.log(
`Sorry, we haven't found any changelog URL for ${strong(name)} module.\n` +
`It would be great if you could fill an issue about this here: ${strong(pkg.bugs.url)}\n` +
'Thanks a lot!'
);
}
break;
case 'homepage':
// Ask user about this module again
modulesToUpdate.unshift(outdatedModule);
if (homepage === undefined) {
console.log('Trying to find homepage URL...');
homepage = outdatedModule.homepage = getModuleHomepage(await getModuleInfo(name));
console.log(err)
return
}
const urls = prepareUrls(protocol, host, port)
message.info(`Server running at ${chalk.cyan(urls.lanUrlForTerminal || urls.localUrlForTerminal)}`)
message.info(`Static resources is served from ${chalk.cyan(dist)}`)
if (proxy) {
const proxyInfo = proxyInfomation(proxy)
if (proxyInfo) {
message.info(`Other HTTP requests will proxy to Proxy-Server base on:\n ${chalk.cyan(proxyInfo)}`)
}
}
if (argv.open) {
opener(urls.localUrlForBrowser)
}
}
const {moduleName} = opts;
console.log(`Trying to find changelog URL for ${strong(moduleName)}...`);
let changelogUrl;
try {
changelogUrl = await findModuleChangelogUrl(moduleName);
} catch (err) {
if (err.code === 'E404') {
console.log("Couldn't find info about this module in npm registry");
return;
}
}
if (changelogUrl) {
console.log(`Opening ${strong(changelogUrl)}...`);
opener(changelogUrl);
} else {
console.log(
"Sorry, we haven't found any changelog URL for this module.\n" +
`It would be great if you could fill an issue about this here: ${strong(pkg.bugs.url)}\n` +
'Thanks a lot!'
);
}
});
setTimeout(() => {
try{
const url = `http://${HOST}:${PORT}`
console.log(`Opening Browser at ${url}`)
const browser = opener(url)
browser.unref();
}catch(err){
console.log("open browser", err.message);
}
}, 4500)
})
import http from 'http';
import express from 'express';
import compression from 'compression';
import opener from 'opener';
const app = express();
app.use(compression());
const server = http.createServer(app);
const isHeroku = 'HEROKU_APP_NAME' in process.env;
app.use(express.static(__dirname + '/example'));
const port = process.env.PORT || 5000;
server.listen(port);
!isHeroku && opener(`http://localhost:${port}`);
import http from 'http';
import { Z_BEST_COMPRESSION } from 'zlib';
import express from 'express';
import compression from 'compression';
import opener from 'opener';
const app = express();
const server = http.createServer(app);
const isHeroku = 'HEROKU_APP_NAME' in process.env;
app.use(compression({ level: Z_BEST_COMPRESSION }));
app.use(express.static(`${__dirname}/example`));
const port = process.env.PORT || 5000;
server.listen(port);
!isHeroku && opener(`http://localhost:${port}`);
const openerPromises = nuxt.server.listeners.map(listener => opener(listener.url))
await Promise.all(openerPromises)