You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.7 KiB
48 lines
1.7 KiB
const web = require('restler')
|
|
const devbug = {
|
|
outs: {},
|
|
options: false,
|
|
out(key, what, group = false){
|
|
if ( !this.options ) console.log('Please specify the DevBug server and project using the dbsetup() method.')
|
|
if ( group ){
|
|
if ( Object.keys(this.outs).includes(group) && typeof this.outs[group] === 'object' ) this.outs[group][key] = what
|
|
else {
|
|
this.outs[group] = {}
|
|
this.outs[group][key] = what
|
|
}
|
|
}
|
|
else this.outs[key] = what
|
|
},
|
|
breakpoint(html = false, name = false){
|
|
if ( !this.options ){ console.log('Please specify the DevBug server and project using the dbsetup() method.'); process.exit(1) }
|
|
const url = this.options.server+'api/v1/out/'+this.options.project
|
|
const caller = (new Error()).stack.split('at')[2].trim()
|
|
web.post(url, {
|
|
multipart: true,
|
|
data: {
|
|
data: JSON.stringify({
|
|
brief: (name ? name : 'Breakpoint: ')+caller,
|
|
data: this.outs
|
|
})
|
|
}
|
|
}).on('complete', (data) => {
|
|
console.log('DevBug POST complete.')
|
|
console.log(data)
|
|
process.exit(0)
|
|
})
|
|
},
|
|
setup(user_options = {}){
|
|
const options = {...{
|
|
server: 'http://localhost:8000/',
|
|
project: '5ab5de6e-a83b-44dc-be28-0727e09170c9'
|
|
}, ...user_options}
|
|
|
|
this.options = options
|
|
}
|
|
}
|
|
global.devbug = devbug
|
|
global.out = devbug.out.bind(devbug)
|
|
global.breakpoint = devbug.breakpoint.bind(devbug)
|
|
global.dbsetup = devbug.setup.bind(devbug)
|
|
module.exports = exports = devbug
|