Break up assetguard.

This commit is contained in:
Daniel Scalzi
2019-03-05 23:05:01 -05:00
parent 1fc118ee8c
commit 5c0a293390
6 changed files with 720 additions and 703 deletions

View File

@@ -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)