Break up assetguard.
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
const { AssetGuard } = require('./assetguard')
|
||||
let target = require('./assetguard')[process.argv[2]]
|
||||
if(target == null){
|
||||
process.send({context: 'error', data: null, error: 'Invalid class name'})
|
||||
console.error('Invalid class name passed to argv[2], cannot continue.')
|
||||
process.exit(1)
|
||||
}
|
||||
let tracker = new target(...(process.argv.splice(3)))
|
||||
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
|
||||
|
||||
const tracker = new AssetGuard(process.argv[2], process.argv[3])
|
||||
//const tracker = new AssetGuard(process.argv[2], process.argv[3])
|
||||
console.log('AssetExec Started')
|
||||
|
||||
// Temporary for debug purposes.
|
||||
@@ -24,8 +30,8 @@ tracker.on('error', (data, error) => {
|
||||
process.on('message', (msg) => {
|
||||
if(msg.task === 'execute'){
|
||||
const func = msg.function
|
||||
let nS = tracker[func]
|
||||
let iS = AssetGuard[func]
|
||||
let nS = tracker[func] // Nonstatic context
|
||||
let iS = target[func] // Static context
|
||||
if(typeof nS === 'function' || typeof iS === 'function'){
|
||||
const f = typeof nS === 'function' ? nS : iS
|
||||
const res = f.apply(f === nS ? tracker : null, msg.argsArr)
|
||||
|
||||
Reference in New Issue
Block a user