shell: no need to promise scoping
This commit is contained in:
@@ -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, { shell: '/bin/bash' });
|
||||
await shell.exec('clear_database', cmd, { shell: '/bin/bash' });
|
||||
}
|
||||
|
||||
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, { shell: '/bin/bash' }));
|
||||
const [error] = await safe(shell.exec('importFromFile', cmd, { shell: '/bin/bash' }));
|
||||
if (error) throw new BoxError(BoxError.DATABASE_ERROR, error);
|
||||
}
|
||||
|
||||
@@ -144,12 +144,12 @@ async function exportToFile(file) {
|
||||
assert.strictEqual(typeof file, 'string');
|
||||
|
||||
// latest mysqldump enables column stats by default which is not present in 5.7 util
|
||||
const mysqlDumpHelp = await shell.promises.exec('exportToFile', '/usr/bin/mysqldump --help', {});
|
||||
const mysqlDumpHelp = await shell.exec('exportToFile', '/usr/bin/mysqldump --help', {});
|
||||
const hasColStats = mysqlDumpHelp.includes('column-statistics');
|
||||
const colStats = hasColStats ? '--column-statistics=0' : '';
|
||||
|
||||
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, { shell: '/bin/bash' }));
|
||||
const [error] = await safe(shell.exec('exportToFile', cmd, { shell: '/bin/bash' }));
|
||||
if (error) throw new BoxError(BoxError.DATABASE_ERROR, error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user