瀏覽代碼

cleanup / refactor

production
pb 3 年之前
父節點
當前提交
5863f4a43d
共有 1 個文件被更改,包括 27 次插入59 次删除
  1. 27
    59
      index.js

+ 27
- 59
index.js 查看文件

@@ -2312,45 +2312,44 @@ acquireElevationState().then(() => {
selectedinstance = Object.assign(detectedInstance, clioverrides);
var todo = Promise.resolve(true);
try {
chessinstances = acquirelocalinstances(selectedinstance);
var promptkeys = {
'instanceName' : processedArgs._[1]
}
var promptkeys = { 'instanceName' : processedArgs._[1] }

var reconfirm = {
'instanceName' : true
var reconfirm = {
'instanceName' : selectedinstance['instanceName'] === 'chess'
}
var prompts = [];
var eachPrompt = function(k, i, a){
// No local instances config found. We use a default initialized instance available in selectedinstance
// Confirm those that were not supplied as user choices in runtime args and proceed to reattempt.
if(promptkeys[k] && selectedinstance[k] !== promptkeys[k] || promptkeys[k] === undefined && selectedinstance[k] === undefined
|| reconfirm[k]) {
prompts.push(async ()=>{
// PB : NOTE -- Important in async cases when this needs to be in the same state as when it was invoked.
// We take a snapshot... Shallow.. !! If required deep should be used based on use case.
// If latest altered state is required we can reerence this directly.
// var asyncthis = Object.assign(this);
Object.defineProperty(selectedinstance, k, getPromptableAsyncPropDescriptor(k, choices[k], promptkeys[k] || selectedinstance[k] ));
return await selectedinstance[k]
})
}

delete promptkeys[k]
}
try {
chessinstances = acquirelocalinstances(selectedinstance);
initinstances(chessinstances, selectedinstance)
var instanceNameChoices = new Set(Object.keys( chessinstances) )
instanceNameChoices.delete('current_run')
instanceNameChoices.add(selectedinstance['instanceName'])
instanceNameChoices.add(promptkeys['instanceName'])
if(promptkeys['instanceName']) instanceNameChoices.add(promptkeys['instanceName'])
var choices = {
'instanceName' : Array.from(instanceNameChoices)
, 'reposerver' : selectedinstance['reposervers']
}
var prompts = [];
var eachPrompt = function(k, i, a){
// No local instances config found. We use a default initialized instance available in selectedinstance
// Confirm those that were not supplied as user choices in runtime args and proceed to reattempt.
if(selectedinstance[k] !== promptkeys[k] || promptkeys[k] === undefined || reconfirm[k]) {
prompts.push(async ()=>{
// PB : NOTE -- Important in async cases when this needs to be in the same state as when it was invoked.
// We take a snapshot... Shallow.. !! If required deep should be used based on use case.
// If latest altered state is required we can reerence this directly.
// var asyncthis = Object.assign(this);
Object.defineProperty(selectedinstance, k, getPromptableAsyncPropDescriptor(k, choices[k], promptkeys[k] || selectedinstance[k] ));
return await selectedinstance[k]
})
}
delete promptkeys[k]
}

Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts)
Object.keys(promptkeys).forEach(eachPrompt, promptkeys)
@@ -2359,51 +2358,20 @@ acquireElevationState().then(() => {
}
catch (e) {
console.error(e)
// Basic keys that must be prompted and confirmed if not supplied as cmd line args.
// PB: TODO --- This should be cmd specific interpretation of location parameters !!!
var promptkeys = {
'instanceName' : processedArgs._[1]
}

var reconfirm = {
'instanceName' : true
}

console.error(e) // Missing chessinstances is not an error...
initinstances(chessinstances, selectedinstance)
var instanceNameChoices = new Set(Object.keys( chessinstances) )
instanceNameChoices.delete('current_run')
instanceNameChoices.add(selectedinstance['instanceName'])
instanceNameChoices.add(promptkeys['instanceName'])
if(promptkeys['instanceName']) instanceNameChoices.add(promptkeys['instanceName'])
var choices = {
'instanceName' : Array.from(instanceNameChoices)
, 'reposerver' : selectedinstance['reposervers']
}
var prompts = [];
var eachPrompt = function(k, i, a){
// No local instances config found. We use a default initialized instance available in selectedinstance
// Confirm those that were not supplied as user choices in runtime args and proceed to reattempt.
if(selectedinstance[k] !== promptkeys[k] || promptkeys[k] === undefined || reconfirm[k]) {
prompts.push(async ()=>{
// PB : NOTE -- Important in async cases when this needs to be in the same state as when it was invoked.
// We take a snapshot... Shallow.. !! If required deep should be used based on use case.
// If latest altered state is required we can reerence this directly.
// var asyncthis = Object.assign(this);
Object.defineProperty(selectedinstance, k, getPromptableAsyncPropDescriptor(k, choices[k], promptkeys[k] || selectedinstance[k] ));
return await selectedinstance[k]
})
}
delete promptkeys[k]
}

Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts)
Object.keys(promptkeys).forEach(eachPrompt, promptkeys)

Loading…
取消
儲存