-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·56 lines (49 loc) · 1.38 KB
/
cli.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env node
var chalk = require('chalk');
var semigrate = require('./semigrate');
function fatal (message) {
console.error('\n' + chalk.bold.red(message));
process.exit(-1);
}
function quit () {
process.exit(0);
}
if (require.main === module){
var argv = require('yargs')
.strict()
.usage('Usage: $0 [options]')
.wrap(80)
.options('reset', {
alias: 'r',
describe: 'Reset the migration information in the database'
})
.options('database', {
describe: 'Specify database to migrate',
demand: true
})
.options('directory', {
default: 'migrations/',
describe: 'Specify where to locate the migrations.'
})
.options('colors', {
default: true,
describe: 'Use colors in the output'
})
.options('migrate', {
default: true,
describe: "Apply the migration scripts. You can override the default value of this option passing `--no-migrate'."
})
.options('dry-run', {
alias: 'n',
describe: 'Show the steps but do not commit changes to the database'
})
.options('load', {
alias: 'l',
describe: 'Load a file after the migration is completed'
})
.version(semigrate.version, 'version')
.help('help')
.alias('help', 'h')
.argv;
semigrate(argv).done(quit, fatal);
}