Commit 68e2b83e authored by Aral Balkan's avatar Aral Balkan

Update sync-related console output formatting

parent 2bc485b8
......@@ -112,7 +112,7 @@ function serve (args) {
// Sync is not supported on Windows as rsync does not exist in that cursed wasteland.
if (syncRequested && process.platform === 'win32') {
console.log(`\n 🤯 [Windows] Sync is not supported on this platform.\n`)
console.log(`\n 🤯 Sync is not supported on Windows.\n`)
return
}
......@@ -141,14 +141,14 @@ function serve (args) {
if (port === 443) {
if (ensure.commandExists('systemctl')) {
if ({ isActive } = status()) {
console.log(`\n 🤯 Error: Cannot start server. Site.js is already running as a daemon on port ${clr(port.toString(), 'cyan')}. Use the ${clr('stop', 'green')} command to stop it.\n`)
console.log(`\n 🤯 Error: Cannot start server. Site.js is already running as a daemon on port ${clr(port.toString(), 'cyan')}. Use the ${clr('stop', 'green')} command to stop it.\n`)
process.exit(1)
}
}
}
// Generic port-in-use error message.
console.log(`\n 🤯 Error: Cannot start server. Port ${clr(port.toString(), 'cyan')} is already in use.\n`)
console.log(`\n 🤯 Error: Cannot start server. Port ${clr(port.toString(), 'cyan')} is already in use.\n`)
process.exit(1)
} else {
......@@ -167,7 +167,7 @@ function serve (args) {
site = new Site(options)
} catch (error) {
if (error instanceof errors.InvalidPathToServeError) {
console.log(` 🤯 ${clr('Error:', 'red')} The path to serve ${clr(options.path, 'yellow')} does not exist.\n`)
console.log(` 🤯 ${clr('Error:', 'red')} The path to serve ${clr(options.path, 'yellow')} does not exist.\n`)
process.exit(1)
} else {
// Rethrow
......@@ -194,7 +194,7 @@ function serve (args) {
if (!syncRequested && exitOnSync) {
// Person has provided the --exit-on-sync option but has not specified where to sync to.
// Warn them and continue.
console.log (` --exit-on-sync option specified without --sync-to option; ignoring.`)
console.log (` --exit-on-sync option specified without --sync-to option; ignoring.`)
}
}
})
......@@ -211,7 +211,7 @@ function syntaxError(message = null) {
// Throw a general error.
function throwError(errorMessage) {
console.log(`\n 🤯 ${errorMessage}\n`)
console.log(`\n 🤯 ${errorMessage}\n`)
throw new Error(errorMessage)
}
......
......@@ -32,16 +32,16 @@ class RSyncWatcher {
// Exit gracefully.
const goodbye = (done) => {
console.log(`\n 💞 [Sync] Exit request detected.`)
console.log(`\n 💫 [Sync] Exit request detected.`)
for (let entry of this.synchronisers) {
let synchroniser = entry[1]
console.log(` 💞 [Sync] Stopping sync process.`)
console.log(` 💫 [Sync] Stopping sync process.`)
synchroniser.process.kill()
}
for (let watcher of this.watchers) {
console.log(` 🔎 [Watch] Removing watcher.`)
console.log(` 🚮 [Watch] Removing watcher.`)
watcher.watcher.close()
}
done()
......@@ -97,7 +97,7 @@ class RSyncWatcher {
rsync.set(optionKey, this.options[project].rsyncOptions[optionKey]);
}
console.log(`\n 💞 [Sync] Starting…`)
console.log(`\n 💫 [Sync] Starting…`)
return new Promise((resolve, reject) => {
const rsyncProcess = rsync.execute((error, code, command) => {
......@@ -106,7 +106,7 @@ class RSyncWatcher {
return
}
console.log(` 💞 [Sync] Complete.\n`)
console.log(` 💫 [Sync] Complete.\n`)
resolve(rsyncProcess.pid)
}, (data) => {
const message = data.toString('ascii')
......@@ -121,17 +121,17 @@ class RSyncWatcher {
const statisticsLine2 = message.match(/total size is ([\d\.]+)K/)
if (message === 'sending incremental file list\n') {
console.log(` 💞 [Sync] Calculating changes…`)
console.log(` 💫 [Sync] Calculating changes…`)
} else if (statisticsLine1 || statisticsLine2) {
if (statisticsLine1) {
console.log(` 💞 [Sync] ↑ ${statisticsLine1[1]} bytes ↓ ${statisticsLine1[2]} bytes (${statisticsLine1[3]} bytes/sec)`)
console.log(` 💫 [Sync] ↑ ${statisticsLine1[1]} bytes ↓ ${statisticsLine1[2]} bytes (${statisticsLine1[3]} bytes/sec)`)
}
if (statisticsLine2) {
console.log(` 💞 [Sync] ${statisticsLine2[1]} KB synced.`)
console.log(` 💫 [Sync] ${statisticsLine2[1]} KB synced.`)
}
} else {
const lines = message.split('\n')
lines.filter(value => value !== '' && !value.startsWith('\r')).forEach(line => console.log(` 💞 [Sync] ${line}`))
lines.filter(value => value !== '' && !value.startsWith('\r')).forEach(line => console.log(` 💫 [Sync] ${line}`))
}
})
......@@ -165,7 +165,7 @@ class RSyncWatcher {
const syncDebounced = debounce(() => {
this.sync(project)
.catch(error => {
console.log(` 💞 [Sync] Error: ${error}`)
console.log(` 💫 [Sync] Error: ${error}`)
})
}, 500)
......
......@@ -25,7 +25,7 @@ function sync (options) {
//
// Start rsync watcher.
//
console.log(`\n 💞 [Sync] Syncing folder ${clr(options.from, 'cyan')} to account ${clr(options.account, 'cyan')} on host ${clr(options.host, 'cyan')}`)
console.log(`\n 💫 [Sync] Syncing folder ${clr(options.from, 'cyan')} to account ${clr(options.account, 'cyan')} on host ${clr(options.host, 'cyan')}`)
const rsyncOptions = {
'sync': {
......@@ -85,38 +85,38 @@ function sync (options) {
const errorCode = errorMatch[1]
const errorMessage = _[errorCode]
if (typeof errorMessage !== 'undefined') {
console.log(` 🤯 [Sync] Error ${errorCode}: ${errorMessage}\n`)
console.log(` 🤯 [Sync] Error ${errorCode}: ${errorMessage}\n`)
console.log(error)
process.exit(1)
}
}
console.log(` 🤯 [Sync] Unknown error: ${error}`)
console.log(` 🤯 [Sync] Unknown error: ${error}`)
process.exit(1)
},
'sync': function () {
// Sync succeeded.
console.log(` 💞 [Sync] Local folder ${clr(options.from, 'cyan')} synced to ${clr(options.host, 'cyan')}`)
console.log(` 💫 [Sync] Local folder ${clr(options.from, 'cyan')} synced to ${clr(options.host, 'cyan')}`)
if (options.exit) {
// We've been asked to exit once we’ve successfully synced. Do so.
console.log('\n 👋 Exit on sync requested, exiting…')
console.log('\n 👋 Exit on sync requested, exiting…')
Graceful.exit()
}
},
'watch': function () {
// Watch succeeded.
console.log(`\n 🔎 [Watch] Watching ${clr(options.from, 'cyan')} for changes to sync to ${clr(options.host, 'cyan')}…\n`)
console.log(`\n 🔎 [Watch] Watching ${clr(options.from, 'cyan')} for changes to sync to ${clr(options.host, 'cyan')}…\n`)
},
'watchEvent': function (event, path) {
// A watch event occurred.
// Capitalise the first letter of the event name (verb).
event = `${event[0].toUpperCase()}${event.slice(1)}`
console.log(` 🔎 [Watch] ${event} ${path}`)
console.log(` 🔎 [Watch] ${event} ${path}`)
},
'watchError': function (error) {
// A watch error occurred.
console.log(`\n 🔎 [Watch] Error: ${error}\n`)
console.log(`\n 🔎 [Watch] Error: ${error}\n`)
process.exit(1)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment