-
Notifications
You must be signed in to change notification settings - Fork 238
/
listen-on-port.js
49 lines (43 loc) · 1.3 KB
/
listen-on-port.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// npm dependencies
const { runErrorServer } = require('./lib/errorServer')
const { verboseLog } = require('./lib/utils/verboseLogger')
const config = require('./lib/config.js').getConfig(null, false)
try {
// local dependencies
const syncChanges = require('./lib/sync-changes')
const server = require('./server.js')
const { generateAssetsSync } = require('./lib/build')
const port = config.port
const proxyPort = port - 50
generateAssetsSync()
if (config.isTest) {
server.listen()
} else {
if (config.isDevelopment) {
console.log('You can manage your prototype at:')
console.log(`http://localhost:${port}/manage-prototype`)
console.log('')
}
console.log('The Prototype Kit is now running at:')
console.log(`http://localhost:${port}`)
console.log('')
if (config.isProduction || !config.useBrowserSync) {
server.listen(port)
} else {
server.listen(proxyPort, () => {
syncChanges.sync({
port,
proxyPort,
files: ['.tmp/public/**/*.*', 'app/views/**/*.*', 'app/assets/**/*.*', 'app/config.json']
})
})
}
}
} catch (e) {
if (config.isDevelopment) {
verboseLog('************************ STARTING ERROR SERVER ***************************')
runErrorServer(e)
} else {
throw e
}
}