1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-02-24 00:22:55 +00:00

Added scriptVersion helper

This commit is contained in:
Bryan Roe
2020-01-16 22:48:21 -08:00
parent a9ef6d0f61
commit 90888b711f
2 changed files with 24 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@@ -93,6 +93,28 @@ switch(process.platform)
return (child.stdout.str.trim());
})()
});
Object.defineProperty(module.exports, 'available', { get: function () { return (this._location!='' ? true : false); } });
Object.defineProperty(module.exports, 'available', { get: function () { return (this._location != '' ? true : false); } });
Object.defineProperty(module.exports, 'scriptVersion',
{
value: (function()
{
var ret = { major: 0, minor: 0 };
if(require('fs').existsSync('/usr/bin/script'))
{
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stderr.on('data', function () { });
child.stdin.write('script -V | awk \'{ split($NF, T, "."); printf "{\\"major\\":%s, \\"minor\\":%s}",T[1],T[2]; }\'\nexit\n');
child.waitExit();
try
{
ret = JSON.parse(child.stdout.str.trim());
}
catch (x)
{ }
}
return (ret);
})()
});
break;
}