UNPKG

ocr

Version:
91 lines (77 loc) 2.97 kB
var exec = require('child_process').exec; var spawn = require("child_process").spawn,child; const validArch = [ 'x64' ]; const validPlatform = [ 'win32', 'linux' ]; var licenseFailedMessage = function() { console.log('***************************************'); console.log('The license manager failed to install a license.'); console.log('If you already have a license installed, then you can ignore this message. Otherwise,'); console.log('Run the following to display the license manager:'); console.log(' > cd node_modules/ocr && npm run register'); console.log('Run the following to install an eval license with your email'); console.log(' > cd node_modules/ocr && npm run register -- youremail@domain.com'); console.log('***************************************'); }; ////////////////////////////////////// if(-1 == validPlatform.indexOf(process.platform)) { console.error('This machine is using a non-supported platform. This has only been tested on Linux and Windows.'); process.exit(); } if(-1 == validArch.indexOf(process.arch)) { console.error('This machine is using an invalid architecture. This has been designed for 64-bit machines only.'); process.exit(); } var emailParam; if (process.argv.length > 2) { emailParam = process.argv[2]; if (emailParam.length > 2 && emailParam.substring(0, 2) === '--') { emailParam = emailParam.substring(2); } } var commandLineParams = '-jar ' + __dirname + '/licensemanager.jar'; if(typeof(emailParam) !== 'undefined') { commandLineParams += ' eval get ' + emailParam + ' requestinstallation'; } // Linux if(process.platform == 'linux') { function runJava() { exec('java ' + commandLineParams, { cwd:'licensing' }, function(error, stdout, stderr) { if (error > 1) { console.error(stderr); licenseFailedMessage(); } else { console.log(stdout); } }); } if (typeof(emailParam) !== 'undefined') { runJava(); } else { exec('type X', { cwd:'licensing' }, function(error, stdout, stderr) { if (error) { console.error(stderr); console.log('***************************************'); console.log('NO WINDOW ENVIRONMENT. You must license manually.'); console.log('Run the following to install an eval license with your email:'); console.log(' > cd node_modules/ocr && npm run register -- youremail@domain.com'); console.log('***************************************'); } else { runJava(); } }); } } // Windows if (process.platform == 'win32') { child = spawn("powershell.exe", [__dirname + "\\runLicenseManager.ps1"]); child.stderr.on("data", function(data) { console.log("" + data); }); child.on("exit", function(code) { if(code != 0) { console.log("License Manager returned with status of " + code); } }); }