Fix error

This commit is contained in:
2020-06-12 11:17:27 -05:00
parent 20e61be50f
commit 1cbb6b5144

View File

@@ -62,62 +62,6 @@ const _vcRuntimeExists = () => {
}); });
}; };
const _detectRepertoryMounts = (version, providerList) => {
return new Promise((resolve, reject) => {
let mountState = {};
const defaultData = {};
for (const provider of providerList) {
defaultData[provider] = {
Active: false,
Location: '',
PID: -1,
};
}
const grabStatus = index => {
if (index >= providerList.length) {
resolve(mountState);
} else {
const provider = providerList[index];
const repertoryExec = _getRepertoryExec(version);
const processOptions = {
cwd: repertoryExec.working,
detached: true,
shell: false,
windowsHide: true,
};
const args = _getDefaultRepertoryArgs(provider, !Constants.PROVIDER_LIST.includes(provider));
args.push('-status');
const process = new spawn(repertoryExec.cmd, args, processOptions);
let result = '';
process.on('error', (err) => {
reject(err);
});
process.stdout.on('data', (d) => {
result += d;
});
process.on('exit', () => {
mountState[provider] = _tryParse(result, defaultData)[provider];
if (mountState[provider].Active &&
((mountState[provider].Location === 'elevating') || (mountState[provider].Location === ''))) {
setTimeout(() => {
grabStatus(index);
}, 2000);
} else {
grabStatus(++index);
}
});
process.unref();
}
};
grabStatus(0);
});
};
const _executeProcess = (command, working, args=[]) => { const _executeProcess = (command, working, args=[]) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let processOptions = { let processOptions = {
@@ -309,7 +253,61 @@ module.exports.createSignatureFiles = (signature, publicKey) => {
}; };
}; };
module.exports.detectRepertoryMounts = _detectRepertoryMounts; module.exports.detectRepertoryMounts = (version, providerList) => {
return new Promise((resolve, reject) => {
let mountState = {};
const defaultData = {};
for (const provider of providerList) {
defaultData[provider] = {
Active: false,
Location: '',
PID: -1,
};
}
const grabStatus = index => {
if (index >= providerList.length) {
resolve(mountState);
} else {
const provider = providerList[index];
const repertoryExec = _getRepertoryExec(version);
const processOptions = {
cwd: repertoryExec.working,
detached: true,
shell: false,
windowsHide: true,
};
const args = _getDefaultRepertoryArgs(provider, !Constants.PROVIDER_LIST.includes(provider));
args.push('-status');
const process = new spawn(repertoryExec.cmd, args, processOptions);
let result = '';
process.on('error', (err) => {
reject(err);
});
process.stdout.on('data', (d) => {
result += d;
});
process.on('exit', () => {
mountState[provider] = _tryParse(result, defaultData)[provider] || defaultData;
if (mountState[provider].Active &&
((mountState[provider].Location === 'elevating') || (mountState[provider].Location === ''))) {
setTimeout(() => {
grabStatus(index);
}, 2000);
} else {
grabStatus(++index);
}
});
process.unref();
}
};
grabStatus(0);
});
};
module.exports.downloadFile = (url, destination, progressCallback, completeCallback) => { module.exports.downloadFile = (url, destination, progressCallback, completeCallback) => {
try { try {