Skip to content
This repository was archived by the owner on Dec 18, 2023. It is now read-only.

Commit ff9949e

Browse files
Merge pull request #16 from livestorm/liv-5388-watch-command
feat: meaningful errors for watch command, liv-5388
2 parents 61a1117 + 654afe5 commit ff9949e

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/cmds/publish.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ function handleResponse({ status }) {
2727
if (status === 201 || status === 204) {
2828
console.log(`Successfully ${status === 201 ? 'created' : 'updated'} plugin 🎉`)
2929
} else {
30-
console.log('upload failed with status ' + status)
30+
if (status === 401) console.log('your API token seems to be incorrect. Please verify that it is valid')
31+
else if (status === 422) console.log('you must set a "name" property to your environment')
32+
else console.log('upload failed with status ' + status)
3133
process.exit(1);
3234
}
3335
}
@@ -46,8 +48,8 @@ module.exports = function publish() {
4648
build()
4749
)
4850
} catch(err) {
49-
console.log(err)
50-
console.log('Are you sure directory is a valid Livestorm plugin ?')
51+
console.log('\x1b[31m', err.output[1].toString())
52+
console.log('\x1b[0m', 'Are you sure directory is a valid Livestorm plugin ?')
5153
process.exit(1);
5254
}
5355
}

src/cmds/watch.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ function updatePlugin(evt, name) {
99
console.log('%s changed', name);
1010
process.stdout.write('\x1b[0m.\x1b[0m')
1111

12-
const res = execSync(`livestorm publish ${env || ''}`).toString()
13-
if (res.includes('Successfully')) {
14-
process.stdout.write('\x1b[92m.\x1b[32m')
12+
try {
13+
const res = execSync(`livestorm publish ${env || ''}`).toString()
14+
if (res.includes('Successfully')) {
15+
process.stdout.write('\x1b[92m.\x1b[32m')
16+
console.log('\x1b[0m')
17+
} else {
18+
throw(res)
19+
}
20+
} catch(err) {
21+
console.log('\x1b[31m', err.stdout.toString())
1522
console.log('\x1b[0m')
16-
} else {
17-
console.log(res)
1823
}
1924
}
2025

0 commit comments

Comments
 (0)