Skip to content

Commit c47a8df

Browse files
committed
Added reset option, TODO: implement db wipe
1 parent dcc75c4 commit c47a8df

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

src/commands/list.command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default async function () {
2626
} else {
2727
const files = await fs.readdir(seedDirectory);
2828

29-
console.log('\nMigrations:\n');
29+
console.log('\NSeeds:\n');
3030

3131
if (files.length === 0) {
3232
console.error(`\nNo seeds found in ${seedDirectory}\n`);

src/commands/seed.command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from 'fs/promises';
33
import Config from '../config';
44
import { confirmation, pool } from '../modules';
55

6-
export default async function (seedName?: string) {
6+
export default async function (seedName?: string, resetOption?: boolean) {
77
const { rootDirectory, seedDirectory } = Config();
88
if (!seedDirectory) {
99
console.error(`Seed directory does not exist!`);
@@ -15,7 +15,7 @@ export default async function (seedName?: string) {
1515
console.error(`${seedName}.sql does not exist!`);
1616
process.exit(1);
1717
}
18-
await confirmation('seed.sql');
18+
await confirmation(`${seedName}.sql`);
1919
const seed = await fs.readFile(seedFilePath, 'utf-8');
2020
await pool.query(seed);
2121
console.log(`\nDatabase seeded\n`);

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import { parser } from './modules/index.js';
33

44
const args = process.argv.slice(2);
5-
const [command, second] = args;
5+
const [command, second, third] = args;
66

7-
await parser({ command, second });
7+
await parser({ command, second, third });
88

99
process.exit(0);

src/modules/parser.module.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
seed,
99
} from '../commands/index.js';
1010

11-
export default async ({ command, second }: IParserInput) => {
11+
export default async ({ command, second, third }: IParserInput) => {
1212
switch (command) {
1313
case '-i':
1414
case 'init':
@@ -42,7 +42,7 @@ export default async ({ command, second }: IParserInput) => {
4242

4343
case '-s':
4444
case 'seed':
45-
seed();
45+
seed(second, !!third);
4646
break;
4747

4848
default:
@@ -56,4 +56,5 @@ export default async ({ command, second }: IParserInput) => {
5656
interface IParserInput {
5757
command: string;
5858
second?: string;
59+
third?: string;
5960
}

0 commit comments

Comments
 (0)