-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
init.ts
36 lines (30 loc) · 884 Bytes
/
init.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Command, flags } from "@oclif/command";
import * as fs from "fs";
import * as Listr from "listr";
import path from "path";
import defaultConfig from "../default-config";
import { DefaultFlags } from "../default-flags";
export default class Init extends Command {
static description = "Creates a basic configuration in the current directory";
static flags = {
help: flags.help({ char: "h" }),
directory: flags.string({
default: "migrations",
char: "d",
description: "Path to migration directory",
}),
...DefaultFlags,
};
async run() {
const { args, flags } = this.parse(Init);
const tasks = new Listr([
{
title: "Creating config",
task() {
fs.writeFileSync(path.resolve(flags.config), defaultConfig(flags.stage, flags.directory));
},
},
]);
await tasks.run();
}
}