Skip to content

Commit 32d1b42

Browse files
committed
feat: prevent crash if missing deps
closes #14 #3 #5 #12
1 parent 5d46824 commit 32d1b42

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ const showToast = (message) => {
6767
}
6868

6969
module.exports = function install(Vue, {debug = false, host = null, port = 8098} = {}) {
70+
// ensure all dependencies are available and bail out if anything is missing
71+
try {
72+
require.resolve('nativescript-socketio')
73+
require.resolve('nativescript-toasty')
74+
require.resolve('@vue/devtools')
75+
} catch (e) {
76+
console.log('[nativescript-vue-devtools] skipping install due to missing dependencies.\n\n', e, '\n\n')
77+
return
78+
}
79+
7080
const startApp = Vue.prototype.$start
7181

7282
Vue.prototype.$start = function () {
@@ -84,6 +94,11 @@ module.exports = function install(Vue, {debug = false, host = null, port = 8098}
8494
return socketIO
8595
} catch (error) {
8696
console.log(error)
97+
// prevent crashing by returning a noop stub
98+
return {
99+
on() {},
100+
emit() {}
101+
}
87102
}
88103
}
89104
})

0 commit comments

Comments
 (0)