Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// serve pure static assets
const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
app.use(staticPath, express.static('./static'))
const uri = config.dev.openBrowserUriHost === 'http://localhost:'? config.dev.openBrowserUriHost + port : config.dev.openBrowserUriHost
var _resolve
var _reject
var readyPromise = new Promise((resolve, reject) => {
_resolve = resolve
_reject = reject
})
var server
var portfinder = require('portfinder')
portfinder.basePort = port
console.log('> Starting dev server...')
devMiddleware.waitUntilValid(() => {
portfinder.getPort((err, port) => {
if (err) {
_reject(err)
}
process.env.PORT = port
var uri = config.dev.openBrowserUriHost === 'http://localhost:'? config.dev.openBrowserUriHost + port : config.dev.openBrowserUriHost
console.log('> Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
opn(uri)
}
server = app.listen(port)
_resolve()
/* eslint-disable no-console, no-process-exit */
import 'colors';
import portfinder from 'portfinder';
import { exec } from 'child-process-promise';
// import ip from 'ip';
portfinder.basePort = 4000;
const SIGINT = 'SIGINT';
let processMap = {};
function output(prefix, message) {
let formattedMessage = message.toString().trim().split('\n')
.reduce((acc, line) => `${acc}${ acc !== '' ? '\n' : '' }${prefix} ${line}`, '');
console.log(formattedMessage);
}
function listen({stdout, stderr}, name) {
stdout.on('data', data => output(`[${name}] `.grey, data));
stderr.on('data', data => output(`[${name}] `.grey, data));
}
// serve pure static assets
const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
app.use(staticPath, express.static('./static'))
const uri = 'http://localhost:' + port
var _resolve
var _reject
var readyPromise = new Promise((resolve, reject) => {
_resolve = resolve
_reject = reject
})
var server
var portfinder = require('portfinder')
portfinder.basePort = port
console.log('> Starting dev server...')
devMiddleware.waitUntilValid(() => {
portfinder.getPort((err, port) => {
if (err) {
_reject(err)
}
process.env.PORT = port
var uri = 'http://localhost:' + port
console.log('> Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
opn(uri)
}
server = app.listen(port)
_resolve()
// serve static posts
app.use('/posts', express.static(__dirname + '/../dist/posts/'))
app.use('/feed.xml', express.static(__dirname + '/../dist/feed.xml'))
const uri = 'http://localhost:' + port
var _resolve
var _reject
var readyPromise = new Promise((resolve, reject) => {
_resolve = resolve
_reject = reject
})
var server
var portfinder = require('portfinder')
portfinder.basePort = port
console.log('> Starting dev server...')
devMiddleware.waitUntilValid(() => {
portfinder.getPort((err, port) => {
if (err) {
_reject(err)
}
process.env.PORT = port
var uri = 'http://localhost:' + port
console.log('> Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
opn(uri)
}
server = app.listen(port)
_resolve()
// 直接打开最新添加的项目,方便调试
let projectList = config.projectConfig.project
let lastedProjectIndex = Object.keys(projectList).length - 1
let lastedProjectUri = uri + '/' + config.projectConfig.staticRoot + '/html/' + Object.keys(projectList)[lastedProjectIndex] + '/index.html'
console.log(`lasted_project_uri => ${lastedProjectUri}`)
var _resolve
var _reject
var readyPromise = new Promise((resolve, reject) => {
_resolve = resolve
_reject = reject
})
var server
var portfinder = require('portfinder')
portfinder.basePort = port
console.log('> Starting dev server...')
devMiddleware.waitUntilValid(() => {
portfinder.getPort((err, port) => {
if (err) {
_reject(err)
}
process.env.PORT = port
console.log('> Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
opn(lastedProjectUri)
}
server = app.listen(port)
_resolve()
})
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port;
// add port to devServer config
devWebpackConfig.devServer.port = port;
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
console.error(err);
});
function listen(p) {
server.listen(p);
log('Listening on port %s', p);
var url = 'http://' + program.address + ':' + p.toString() + '/' + (program.url || '');
if (program.open) {
verbose('Opening browser...');
!program.log && console.log(pkg.name + ' running at %s', url);
opener(url);
}
}
if (!program.port) {
portfinder.basePort = defaults.basePort;
portfinder.getPort(function (err, port) {
if (err) throw err;
listen(port);
});
} else {
listen(program.port);
}
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = webpackDevConfig.devServer.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
webpackDevConfig.devServer.port = port
webpackDevConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Webpack dev server is listening: http://${webpackDevConfig.devServer.host}:${port}`],
},
}))
resolve(webpackDevConfig)
}
})
})