shell: add options to exec

This commit is contained in:
Girish Ramakrishnan
2024-02-20 21:11:09 +01:00
parent 7ce5b53753
commit 26eb739b46
9 changed files with 45 additions and 44 deletions

View File

@@ -78,7 +78,7 @@ async function clear() {
await fs.promises.writeFile('/tmp/extra.cnf', `[client]\nhost=${gDatabase.hostname}\nuser=${gDatabase.username}\npassword=${gDatabase.password}\ndatabase=${gDatabase.name}`, 'utf8');
const cmd = 'mysql --defaults-extra-file=/tmp/extra.cnf -Nse "SHOW TABLES" | grep -v "^migrations$" | while read table; do mysql --defaults-extra-file=/tmp/extra.cnf -e "SET FOREIGN_KEY_CHECKS = 0; TRUNCATE TABLE $table"; done';
await shell.promises.exec('clear_database', cmd);
await shell.promises.exec('clear_database', cmd, {});
}
async function query() {
@@ -136,7 +136,7 @@ async function importFromFile(file) {
const cmd = `/usr/bin/mysql -h "${gDatabase.hostname}" -u ${gDatabase.username} -p${gDatabase.password} ${gDatabase.name} < ${file}`;
await query('CREATE DATABASE IF NOT EXISTS box');
const [error] = await safe(shell.promises.exec('importFromFile', cmd));
const [error] = await safe(shell.promises.exec('importFromFile', cmd, {}));
if (error) throw new BoxError(BoxError.DATABASE_ERROR, error);
}
@@ -151,6 +151,6 @@ async function exportToFile(file) {
const cmd = `/usr/bin/mysqldump -h "${gDatabase.hostname}" -u root -p${gDatabase.password} ${colStats} --single-transaction --routines --triggers ${gDatabase.name} > "${file}"`;
const [error] = await safe(shell.promises.exec('exportToFile', cmd));
const [error] = await safe(shell.promises.exec('exportToFile', cmd, {}));
if (error) throw new BoxError(BoxError.DATABASE_ERROR, error);
}