shell: remove usage of .spawn

This commit is contained in:
Girish Ramakrishnan
2024-02-21 13:09:59 +01:00
parent 62ca0487dc
commit 2237d2bbb7
5 changed files with 86 additions and 78 deletions

View File

@@ -65,16 +65,10 @@ async function downloadUrl(url, file) {
safe.fs.unlinkSync(file);
await promiseRetry({ times: 10, interval: 5000, debug }, async function () {
debug(`Downloading ${url} to ${file}`);
const args = `-s --fail ${url} -o ${file}`;
debug(`downloadUrl: curl ${args}`);
const [error] = await safe(shell.promises.spawn('downloadUrl', '/usr/bin/curl', args.split(' '), {}));
debug(`downloadUrl: downloading ${url} to ${file}`);
const [error] = await safe(shell.promises.exec('downloadUrl', `curl -s --fail ${url} -o ${file}`, {}));
if (error) throw new BoxError(BoxError.NETWORK_ERROR, `Failed to download ${url}: ${error.message}`);
debug(`downloadUrl: downloaded ${url} to ${file}`);
debug('downloadUrl: done');
});
}
@@ -103,16 +97,13 @@ async function extractTarball(tarball, dir) {
assert.strictEqual(typeof tarball, 'string');
assert.strictEqual(typeof dir, 'string');
const args = `-zxf ${tarball} -C ${dir}`;
debug(`extractTarball: extracting ${tarball} to ${dir}`);
debug(`extractTarball: tar ${args}`);
const [error] = await safe(shell.promises.spawn('extractTarball', '/bin/tar', args.split(' '), {}));
const [error] = await safe(shell.promises.exec('extractTarball', `tar -zxf ${tarball} -C ${dir}`, {}));
if (error) throw new BoxError(BoxError.FS_ERROR, `Failed to extract release package: ${error.message}`);
safe.fs.unlinkSync(tarball);
debug(`extractTarball: extracted ${tarball} to ${dir}`);
debug('extractTarball: extracted');
}
async function verifyUpdateInfo(versionsFile, updateInfo) {