UNPKG

@adonisjs/lucid

Version:

SQL ORM built on top of Active Record pattern

50 lines (49 loc) 1.36 kB
"use strict"; /* * @adonisjs/lucid * * (c) Harminder Virk <virk@adonisjs.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.TestsSeeder = void 0; /** * Seeder class to be used for testing */ class TestsSeeder { constructor(ace, connectionName) { Object.defineProperty(this, "ace", { enumerable: true, configurable: true, writable: true, value: ace }); Object.defineProperty(this, "connectionName", { enumerable: true, configurable: true, writable: true, value: connectionName }); } async runCommand(commandName) { const args = ['--compact-output']; if (this.connectionName) { args.push(`--connection=${this.connectionName}`); } const command = await this.ace.exec(commandName, args); if (command.exitCode) { if (command.error) { throw command.error; } else { throw new Error(`"${commandName}" failed`); } } } async run() { await this.runCommand('db:seed'); } } exports.TestsSeeder = TestsSeeder;