Bladeren bron

suppressed prompts for defaults

master
pb 3 jaren geleden
bovenliggende
commit
8479e69b1d
6 gewijzigde bestanden met toevoegingen van 61 en 309 verwijderingen
  1. 3
    1
      bin/elxr
  2. 22
    111
      elxr.js
  3. 24
    113
      i.js
  4. 10
    9
      index.js
  5. 2
    2
      package.json
  6. 0
    73
      windowselevate.hta

+ 3
- 1
bin/elxr Bestand weergeven

@@ -3,9 +3,11 @@
var ENV = Object.assign({}, process.env); // Shallow clone it.

const spawn = require('child_process').spawn;
console.dir(process.argv.slice(2))

const child = spawn(
(process.platform === 'win32' ? 'npm.cmd' : 'npm')
, ['run', 'index'].concat(process.argv.slice(2)), { cwd: __dirname });
, ['run', 'index', '--'].concat(process.argv.slice(2)), { cwd: __dirname });

// const child = spawn(
// 'C:\\Program Files\\Git\\bin\\sh.exe'

+ 22
- 111
elxr.js Bestand weergeven

@@ -463,9 +463,10 @@ var op = {
Object.keys(processedArgs).forEach((v) => { v != '_' ? namedArgs.push('--' + v + '=' + processedArgs[v]) : null; });
// PB : TODO -- Convert all the cli args back to string.
var args = [`${selectedinstance.root}/.elxr/run-${runtimestamp}/windowselevate.hta`].concat(processedArgs._).concat(namedArgs.join(' ')); args.push('--runas=self');
args.push('--nodepath=' + r[r.length - 1]);
if (!processedArgs.node_env) args.push('--node_env=' + ENV.NODE_ENV);
if (processedArgs.debug) args.push('--debug=true'); // Enable to debug elevated..
// args.push('--nodepath=' + r.messages[r.messages.length - 1])
// if (!processedArgs.node_env) args.push('--node_env=' + ENV.NODE_ENV)
// if (processedArgs.debug) args.push('--debug=true') // Enable to debug elevated..
console.dir(processedArgs);

return nodeShellExec('MSHTA', [`"${args.join('" "')}"`]
, {
@@ -1805,97 +1806,6 @@ function elxrworker() {
else return __runcmd(processedArgs.label || processedArgs._[0] || 'h');
}

function acquireChoices(selectedinstance) {
console.warn(chalk.cyan(`
-------------------------------------------------------------------------------
Warning : Cannot locate your preferred configuration since it was not specified
You should fork the default chess configuration to customize and make it
your own instance with a named config as
{{yourowninstancename}}-config-{{yourchosenenvironment}}
And then run this tool as follows
NODE_ENV={{yourchosenenvironment}} elxr i {{yourowninstancename}}
OR
Run this tool with the following command to use a quick start default.
elxr --default
OR
Choose one of the options below to run interactively.

We will run your choice at the next prompt.
-------------------------------------------------------------------------------
`));
var prompt = cli.prompter;
return prompt.ask(`Choose an option :
d) Install the default chess instance.
=> elxr i chess node_env=development --default
n) Create your custom new instance interactively
=> elxr i {{instanceName}} node_env={{environment}}
i) Choose an instance and environment to install
=> elxr i {{instanceName}} node_env={{environment}}
c) Choose a command to run ( pull, use, i, npmi ... ) <= pull
=> elxr {{cmd}} {{instanceName}} node_env={{environment}}
h) Help
q) Quit
Default <= d
: `).then((choice) => {
if (choice && choice === 'd' || !choice) {
processedArgs._[0] = 'i';
selectedinstance.instanceName = processedArgs._[1] = processedArgs._[1] || 'chess';
selectedinstance.node_env = processedArgs.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()) || processedArgs.node_env || 'development';
selectedinstance.reposerver = 'https://git.bbh.org.in';
}
else if (choice === 'h') {
processedArgs._[0] = 'h';
fs.writeFileSync('run.done', 'noop help');
console.log(elxr.help()); process.exit();
}
else if (choice === 'n' || choice === 'i') {
var p1 = cli.prompter;
return p1.ask(`Enter Instance Name ( <= ${selectedinstance.instanceName} ) : `).then(function (instanceName) {
processedArgs._[0] = 'i';
selectedinstance.instanceName = processedArgs._[1] = instanceName || selectedinstance.instanceName;
return p1.ask(`Enter Environment ( <= ${selectedinstance.node_env} ) : `).then(function (node_env) {
selectedinstance.node_env = processedArgs.node_env = node_env || selectedinstance.node_env;
if (choice === 'n') {
selectedinstance.reposerver = 'https://git.bbh.org.in';
console.warn(
chalk.magenta('No Option Available. Your account may not have privileges. You can request here http://git.bbh.org.in/chess'));
process.exit();
}

return p1.ask(`Enter preferred repo server ( <= ${selectedinstance.reposerver || selectedinstance.reposervers[0]} ) : `).then(function (reposerver) {
selectedinstance.reposerver = reposerver || selectedinstance.reposervers[0] || 'https://git.bbh.org.in';
})
})
})
} else if (choice === 'c') {
var p1 = cli.prompter;
return p1.ask(`Enter Instance Name ( <= ${selectedinstance.instanceName} ) : `).then(function (instanceName) {
selectedinstance.instanceName = processedArgs._[1] = instanceName || selectedinstance.instanceName;
return p1.ask(`Enter Environment ( <= ${selectedinstance.node_env} ) : `).then(function (node_env) {
selectedinstance.node_env = processedArgs.node_env = node_env || selectedinstance.node_env;
return p1.ask(`Enter cmd :
p) pull
Default <= p
: `).then(function (cmd) {
if (!cmd || cmd === 'p') {
processedArgs._[0] = 'pull';
}
else processedArgs._[0] = cmd;
return p1.ask(`Enter preferred repo server ( <= ${selectedinstance.reposerver || selectedinstance.reposervers[0]} ) : `).then(function (reposerver) {
selectedinstance.reposerver = reposerver || selectedinstance.reposerver || selectedinstance.reposervers[0] || 'https://git.bbh.org.in';
})
})
})
})
} else {
console.log(chalk.gray(`Default option not exercised. Please follow manual instructions to customize your instance here http://git.bbh.org.in/chess and try again.`));
fs.writeFileSync('run.log', ', ' + JSON.stringify({ success: 'quit without execution' }), { 'flag': 'a+' });
fs.writeFileSync('run.done', 'noop quit');
process.exit();
}
})
}

var mergeObjByKey = function(arrOfObjs, keyName) {

var keyedDistinct = {};
@@ -2125,6 +2035,11 @@ var detectinstances = function () {

};

if(clioverrides.reconfirm) {
var reconfirm = { 'instanceName' : clioverrides['instanceName'] === 'chess' };
}
else { var reconfirm = {}; }

var getBoundEachPrompt = function(target, mustPrompt, promptables, choices) {
return function(prompts, k, i, a){
@@ -2149,7 +2064,7 @@ var getBoundEachPrompt = function(target, mustPrompt, promptables, choices) {
}
};

var __interactve_promts = function( target, choices ){
var __interactive_prompts = function( target, choices ){

Object.defineProperty(target, 'node_env', { get : function(){ return this.instanceType } });

@@ -2378,7 +2293,7 @@ function verifyAndInstallPrerequisites() {
// https://devblogs.microsoft.com/scripting/how-can-i-pass-command-line-variables-to-an-hta-when-it-starts/
// alert(windowselevate.commandLine)
var args = windowselevate.commandLine.split('"').slice(3);
alert(args)
// alert(args)
var processedArgs = { _ : [] }
var namedArgs = [];
for(var item in args){
@@ -2395,7 +2310,7 @@ function verifyAndInstallPrerequisites() {
// PB : TODO -- Convert all the cli args back to string.
var cargs = (processedArgs.debug ? '--inspect-brk=9228' : '') + ' elxr ' + processedArgs._.join(' ') + ' ' + namedArgs.join(' ');
alert(cargs)
// alert(cargs)
var shell = new ActiveXObject('shell.application');
// alert('launching node privilged. ' + processedArgs['nodepath'])
// shell.ShellExecute('where', 'node', '', '', 10);
@@ -2588,7 +2503,7 @@ acquireElevationState().then(() => {
chessinstances[instanceName][node_env]
, clioverrides
, selected_overrides
// , __interactve_promts -- Cant just override. Also need selectedinstance to be ready...
// , __interactive_prompts -- Cant just override. Also need selectedinstance to be ready...
);

// chessinstances[instanceName] = chessinstances[instanceName] || {}
@@ -2682,7 +2597,7 @@ acquireElevationState().then(() => {
});
instances = instances.concat(detectedinstanceoptions);

if(promptkeys['instanceName']) instnaceNames.push(selectedinstance['instanceName']);
if(selectedinstance['instanceName']) instnaceNames.push(selectedinstance['instanceName']);
if(promptkeys['instanceName']) instnaceNames.push(promptkeys['instanceName']);
if(selectedinstance['reposervers']) reposervers = reposervers.concat(selectedinstance['reposervers']);
@@ -2701,33 +2616,29 @@ acquireElevationState().then(() => {

// PB : TODO -- Most recent should be at the tip ! at index 0 so utils.reverseassign is required !!!
selectedinstance = utils.assign( ...detectedinstanceoptions.slice(-2) );
promptkeys = utils.assign(promptkeys, clioverrides);
if(clioverrides.reconfirm) {
({ 'instanceName' : selectedinstance['instanceName'] === 'chess' });
}
// promptkeys = utils.assign(promptkeys, clioverrides)
try {

chessinstances = acquirelocalinstances(selectedinstance);
findlocalinstances(chessinstances, detectedinstanceoptions);
initinstances(selectedinstance); // use the local instances for defaults if at all possible.
var choices = getchoices(detectedinstanceoptions, promptkeys);
var todo = any( __interactve_promts(selectedinstance, choices) ).then(()=>{
var todo = any( __interactive_prompts(selectedinstance, choices) ).then(()=>{
return initinstances(selectedinstance)
});
}
catch (e) {
// PB : TODO -- verbose mode warning.. console.warn(e) // Missing chessinstances is not an error...
var choices = getchoices(detectedinstanceoptions, promptkeys);
var todo = any( __interactve_promts(selectedinstance, choices) ).then(()=>{
var todo = any( __interactive_prompts(selectedinstance, choices) ).then(()=>{
return initinstances(selectedinstance)
});

if(!processedArgs._[0] || !selectedinstance.node_env || !selectedinstance.instanceName){
// Weve not been told what to do.
todo = todo.then(() => { return acquireChoices(selectedinstance) });
}
// if(!processedArgs._[0] || !selectedinstance.node_env || !selectedinstance.instanceName){
// // Weve not been told what to do.
// todo = todo.then(() => { return acquireChoices(selectedinstance) })
// }
todo = todo.then(() => {
try {

+ 24
- 113
i.js Bestand weergeven

@@ -1,4 +1,4 @@
/* Version: 1.0.0 - September 29, 2021 17:16:55 */
/* Version: 1.0.0 - September 29, 2021 19:31:21 */
'use strict';

var path$1 = require('path');
@@ -25526,7 +25526,7 @@ var nodeShellExec = cliverse.nodeShellExec;


const __ALIAS__STAMP__ = '9e7bebe0-1f57-11ec-8f88-778ffeea9d1b';
const BUILD_VERSION = 'Version: 1.0.0 - built on September 29, 2021 17:16:55';
const BUILD_VERSION = 'Version: 1.0.0 - built on September 29, 2021 19:31:21';
const runtimestamp = (new Date()).getTime();
function getVersion() { return BUILD_VERSION; }
console.log(getVersion());
@@ -25976,9 +25976,10 @@ var op = {
Object.keys(processedArgs).forEach((v) => { v != '_' ? namedArgs.push('--' + v + '=' + processedArgs[v]) : null; });
// PB : TODO -- Convert all the cli args back to string.
var args = [`${selectedinstance.root}/.elxr/run-${runtimestamp}/windowselevate.hta`].concat(processedArgs._).concat(namedArgs.join(' ')); args.push('--runas=self');
args.push('--nodepath=' + r[r.length - 1]);
if (!processedArgs.node_env) args.push('--node_env=' + ENV.NODE_ENV);
if (processedArgs.debug) args.push('--debug=true'); // Enable to debug elevated..
// args.push('--nodepath=' + r.messages[r.messages.length - 1])
// if (!processedArgs.node_env) args.push('--node_env=' + ENV.NODE_ENV)
// if (processedArgs.debug) args.push('--debug=true') // Enable to debug elevated..
console.dir(processedArgs);

return nodeShellExec('MSHTA', [`"${args.join('" "')}"`]
, {
@@ -27318,97 +27319,6 @@ function elxrworker() {
else return __runcmd(processedArgs.label || processedArgs._[0] || 'h');
}

function acquireChoices(selectedinstance) {
console.warn(source.cyan(`
-------------------------------------------------------------------------------
Warning : Cannot locate your preferred configuration since it was not specified
You should fork the default chess configuration to customize and make it
your own instance with a named config as
{{yourowninstancename}}-config-{{yourchosenenvironment}}
And then run this tool as follows
NODE_ENV={{yourchosenenvironment}} elxr i {{yourowninstancename}}
OR
Run this tool with the following command to use a quick start default.
elxr --default
OR
Choose one of the options below to run interactively.

We will run your choice at the next prompt.
-------------------------------------------------------------------------------
`));
var prompt = cliverse.prompter;
return prompt.ask(`Choose an option :
d) Install the default chess instance.
=> elxr i chess node_env=development --default
n) Create your custom new instance interactively
=> elxr i {{instanceName}} node_env={{environment}}
i) Choose an instance and environment to install
=> elxr i {{instanceName}} node_env={{environment}}
c) Choose a command to run ( pull, use, i, npmi ... ) <= pull
=> elxr {{cmd}} {{instanceName}} node_env={{environment}}
h) Help
q) Quit
Default <= d
: `).then((choice) => {
if (choice && choice === 'd' || !choice) {
processedArgs._[0] = 'i';
selectedinstance.instanceName = processedArgs._[1] = processedArgs._[1] || 'chess';
selectedinstance.node_env = processedArgs.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()) || processedArgs.node_env || 'development';
selectedinstance.reposerver = 'https://git.bbh.org.in';
}
else if (choice === 'h') {
processedArgs._[0] = 'h';
fs.writeFileSync('run.done', 'noop help');
console.log(elxr.help()); process.exit();
}
else if (choice === 'n' || choice === 'i') {
var p1 = cliverse.prompter;
return p1.ask(`Enter Instance Name ( <= ${selectedinstance.instanceName} ) : `).then(function (instanceName) {
processedArgs._[0] = 'i';
selectedinstance.instanceName = processedArgs._[1] = instanceName || selectedinstance.instanceName;
return p1.ask(`Enter Environment ( <= ${selectedinstance.node_env} ) : `).then(function (node_env) {
selectedinstance.node_env = processedArgs.node_env = node_env || selectedinstance.node_env;
if (choice === 'n') {
selectedinstance.reposerver = 'https://git.bbh.org.in';
console.warn(
source.magenta('No Option Available. Your account may not have privileges. You can request here http://git.bbh.org.in/chess'));
process.exit();
}

return p1.ask(`Enter preferred repo server ( <= ${selectedinstance.reposerver || selectedinstance.reposervers[0]} ) : `).then(function (reposerver) {
selectedinstance.reposerver = reposerver || selectedinstance.reposervers[0] || 'https://git.bbh.org.in';
})
})
})
} else if (choice === 'c') {
var p1 = cliverse.prompter;
return p1.ask(`Enter Instance Name ( <= ${selectedinstance.instanceName} ) : `).then(function (instanceName) {
selectedinstance.instanceName = processedArgs._[1] = instanceName || selectedinstance.instanceName;
return p1.ask(`Enter Environment ( <= ${selectedinstance.node_env} ) : `).then(function (node_env) {
selectedinstance.node_env = processedArgs.node_env = node_env || selectedinstance.node_env;
return p1.ask(`Enter cmd :
p) pull
Default <= p
: `).then(function (cmd) {
if (!cmd || cmd === 'p') {
processedArgs._[0] = 'pull';
}
else processedArgs._[0] = cmd;
return p1.ask(`Enter preferred repo server ( <= ${selectedinstance.reposerver || selectedinstance.reposervers[0]} ) : `).then(function (reposerver) {
selectedinstance.reposerver = reposerver || selectedinstance.reposerver || selectedinstance.reposervers[0] || 'https://git.bbh.org.in';
})
})
})
})
} else {
console.log(source.gray(`Default option not exercised. Please follow manual instructions to customize your instance here http://git.bbh.org.in/chess and try again.`));
fs.writeFileSync('run.log', ', ' + JSON.stringify({ success: 'quit without execution' }), { 'flag': 'a+' });
fs.writeFileSync('run.done', 'noop quit');
process.exit();
}
})
}

var mergeObjByKey = function(arrOfObjs, keyName) {

var keyedDistinct = {};
@@ -27638,6 +27548,11 @@ var detectinstances = function () {

};

if(clioverrides.reconfirm) {
var reconfirm = { 'instanceName' : clioverrides['instanceName'] === 'chess' };
}
else { var reconfirm = {}; }

var getBoundEachPrompt = function(target, mustPrompt, promptables, choices) {
return function(prompts, k, i, a){
@@ -27662,7 +27577,7 @@ var getBoundEachPrompt = function(target, mustPrompt, promptables, choices) {
}
};

var __interactve_promts = function( target, choices ){
var __interactive_prompts = function( target, choices ){

Object.defineProperty(target, 'node_env', { get : function(){ return this.instanceType } });

@@ -27889,7 +27804,7 @@ function verifyAndInstallPrerequisites() {
// https://devblogs.microsoft.com/scripting/how-can-i-pass-command-line-variables-to-an-hta-when-it-starts/
// alert(windowselevate.commandLine)
var args = windowselevate.commandLine.split('"').slice(3);
alert(args)
// alert(args)
var processedArgs = { _ : [] }
var namedArgs = [];
for(var item in args){
@@ -27906,7 +27821,7 @@ function verifyAndInstallPrerequisites() {
// PB : TODO -- Convert all the cli args back to string.
var cargs = (processedArgs.debug ? '--inspect-brk=9228' : '') + ' elxr ' + processedArgs._.join(' ') + ' ' + namedArgs.join(' ');
alert(cargs)
// alert(cargs)
var shell = new ActiveXObject('shell.application');
// alert('launching node privilged. ' + processedArgs['nodepath'])
// shell.ShellExecute('where', 'node', '', '', 10);
@@ -28099,7 +28014,7 @@ acquireElevationState().then(() => {
chessinstances[instanceName][node_env]
, clioverrides
, selected_overrides
// , __interactve_promts -- Cant just override. Also need selectedinstance to be ready...
// , __interactive_prompts -- Cant just override. Also need selectedinstance to be ready...
);

// chessinstances[instanceName] = chessinstances[instanceName] || {}
@@ -28193,7 +28108,7 @@ acquireElevationState().then(() => {
});
instances = instances.concat(detectedinstanceoptions);

if(promptkeys['instanceName']) instnaceNames.push(selectedinstance['instanceName']);
if(selectedinstance['instanceName']) instnaceNames.push(selectedinstance['instanceName']);
if(promptkeys['instanceName']) instnaceNames.push(promptkeys['instanceName']);
if(selectedinstance['reposervers']) reposervers = reposervers.concat(selectedinstance['reposervers']);
@@ -28212,33 +28127,29 @@ acquireElevationState().then(() => {

// PB : TODO -- Most recent should be at the tip ! at index 0 so utils.reverseassign is required !!!
selectedinstance = bbhverse.assign( ...detectedinstanceoptions.slice(-2) );
promptkeys = bbhverse.assign(promptkeys, clioverrides);
if(clioverrides.reconfirm) {
({ 'instanceName' : selectedinstance['instanceName'] === 'chess' });
}
// promptkeys = utils.assign(promptkeys, clioverrides)
try {

chessinstances = acquirelocalinstances(selectedinstance);
findlocalinstances(chessinstances, detectedinstanceoptions);
initinstances(selectedinstance); // use the local instances for defaults if at all possible.
var choices = getchoices(detectedinstanceoptions, promptkeys);
var todo = any( __interactve_promts(selectedinstance, choices) ).then(()=>{
var todo = any( __interactive_prompts(selectedinstance, choices) ).then(()=>{
return initinstances(selectedinstance)
});
}
catch (e) {
// PB : TODO -- verbose mode warning.. console.warn(e) // Missing chessinstances is not an error...
var choices = getchoices(detectedinstanceoptions, promptkeys);
var todo = any( __interactve_promts(selectedinstance, choices) ).then(()=>{
var todo = any( __interactive_prompts(selectedinstance, choices) ).then(()=>{
return initinstances(selectedinstance)
});

if(!processedArgs._[0] || !selectedinstance.node_env || !selectedinstance.instanceName){
// Weve not been told what to do.
todo = todo.then(() => { return acquireChoices(selectedinstance) });
}
// if(!processedArgs._[0] || !selectedinstance.node_env || !selectedinstance.instanceName){
// // Weve not been told what to do.
// todo = todo.then(() => { return acquireChoices(selectedinstance) })
// }
todo = todo.then(() => {
try {

+ 10
- 9
index.js Bestand weergeven

@@ -466,9 +466,10 @@ var op = {
Object.keys(processedArgs).forEach((v) => { v != '_' ? namedArgs.push('--' + v + '=' + processedArgs[v]) : null; })
// PB : TODO -- Convert all the cli args back to string.
var args = [`${selectedinstance.root}/.elxr/run-${runtimestamp}/windowselevate.hta`].concat(processedArgs._).concat(namedArgs.join(' ')); args.push('--runas=self');
args.push('--nodepath=' + r[r.length - 1])
if (!processedArgs.node_env) args.push('--node_env=' + ENV.NODE_ENV)
if (processedArgs.debug) args.push('--debug=true') // Enable to debug elevated..
// args.push('--nodepath=' + r.messages[r.messages.length - 1])
// if (!processedArgs.node_env) args.push('--node_env=' + ENV.NODE_ENV)
// if (processedArgs.debug) args.push('--debug=true') // Enable to debug elevated..
console.dir(processedArgs)

return nodeShellExec('MSHTA', [`"${args.join('" "')}"`]
, {
@@ -2750,7 +2751,7 @@ acquireElevationState().then(() => {
})
instances = instances.concat(detectedinstanceoptions)

if(promptkeys['instanceName']) instnaceNames.push(selectedinstance['instanceName'])
if(selectedinstance['instanceName']) instnaceNames.push(selectedinstance['instanceName'])
if(promptkeys['instanceName']) instnaceNames.push(promptkeys['instanceName'])
if(selectedinstance['reposervers']) reposervers = reposervers.concat(selectedinstance['reposervers'])
@@ -2769,7 +2770,7 @@ acquireElevationState().then(() => {

// PB : TODO -- Most recent should be at the tip ! at index 0 so utils.reverseassign is required !!!
selectedinstance = utils.assign( ...detectedinstanceoptions.slice(-2) )
promptkeys = utils.assign(promptkeys, clioverrides)
// promptkeys = utils.assign(promptkeys, clioverrides)
try {

@@ -2788,10 +2789,10 @@ acquireElevationState().then(() => {
return initinstances(selectedinstance)
})

if(!processedArgs._[0] || !selectedinstance.node_env || !selectedinstance.instanceName){
// Weve not been told what to do.
todo = todo.then(() => { return acquireChoices(selectedinstance) })
}
// if(!processedArgs._[0] || !selectedinstance.node_env || !selectedinstance.instanceName){
// // Weve not been told what to do.
// todo = todo.then(() => { return acquireChoices(selectedinstance) })
// }
todo = todo.then(() => {
try {

+ 2
- 2
package.json Bestand weergeven

@@ -5,8 +5,8 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build-commented": "rollup index.js --format cjs --file elxr.js",
"build": "rollup -c",
"build-elxr": "rollup index.js --format cjs --file elxr.js",
"build": "rollup -c && rollup index.js --format cjs --file elxr.js",
"index": "SET FORCE_COLOR=true && node index"
},
"keywords": [],

+ 0
- 73
windowselevate.hta Bestand weergeven

@@ -1,73 +0,0 @@

<html><HTA:APPLICATION ID="windowselevate" icon="#"/>
<script language="vbscript">
document.title = "elxr control panel"
self.ResizeTo 200,600
Sub Window_Onload
self.MoveTo (screen.availWidth - (document.body.clientWidth + 40)),10
End Sub

Set objShell = CreateObject("WScript.Shell")
Set objENV = objShell.Environment("Process")
dim NODE_ENV
NODE_ENV = objENV("NODE_ENV")
</script>

<script language="javascript">
//WINDOWSTATE="minimize" SHOWINTASKBAR="no" SYSMENU="no" CAPTION="no"
// https://devblogs.microsoft.com/scripting/how-can-i-pass-command-line-variables-to-an-hta-when-it-starts/
// alert(windowselevate.commandLine)
var args = windowselevate.commandLine.split('"').slice(3);
// alert(args)
var processedArgs = { _ : [] }
var namedArgs = [];
for(var item in args){
if(args[item].charAt(0) === '-'){
namedArgs.push(args[item])
var split = args[item].split('=');
processedArgs[split[0].slice(2)] = split[1] || true;
}
else processedArgs._.push(args[item]);
}
// args = args.forEach(function(item){ })
// alert('processedArgs._ : ' + processedArgs._);
// alert(processedArgs.runas);
// PB : TODO -- Convert all the cli args back to string.
var cargs = (processedArgs.debug ? '--inspect-brk=9228' : '') + ' elxr ' + processedArgs._.join(' ') + ' ' + namedArgs.join(' ');
// alert(cargs)
var shell = new ActiveXObject('shell.application');
// alert('launching node privilged. ' + processedArgs['nodepath'])
// shell.ShellExecute('where', 'node', '', '', 10);
shell.ShellExecute('node', cargs, '', 'runas', 1);
// shell.ShellExecute(processedArgs['nodepath'], cargs, '', 'runas', 1);
var fso = new ActiveXObject('Scripting.FileSystemObject');
window.onload = function() {
document.body.style.backgroundColor = 'black';
document.body.style.fontFamily = 'arial';
var log = document.createElement('div');
log.innerHTML='Please Wait';
function l(msg){ log.innerHTML+= msg; };
log.style.color = 'blue';
log.style.width = '95%';
log.id = 'log';
document.body.appendChild(log);
l('<Br/>Current config : ')
l('<Br/>NODE_ENV = ' + NODE_ENV)
l('<Br/>cmd = ' + processedArgs._[0])
processedArgs._[1] === 'use' ? l('<Br/>using = ' + processedArgs._[2]) : null;
l('<Br/><Br/>')
var timer = function(){
l('.');
if(fso.FileExists("run.done")) close();
else window.setTimeout(timer, 1000);
};
window.setTimeout(timer, 3000);
};
</script>
</html>

Laden…
Annuleren
Opslaan