Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.

Commit f6787a7

Browse files
committed
Tweaks
1 parent 4ab9c4d commit f6787a7

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/cli.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ async function main (args) {
4848
yargs.showHelp()
4949
})
5050

51-
let exitCode = 0
5251

5352
try {
5453
const { data } = await new YargsPromise(cli).parse(args)
@@ -63,11 +62,7 @@ async function main (args) {
6362
print('Unknown error, please re-run the command with DEBUG=repo-migrations:cli to see debug output')
6463
}
6564

66-
exitCode = 1
67-
}
68-
69-
if (exitCode) {
70-
process.exit(exitCode)
65+
process.exit(1)
7166
}
7267
}
7368

src/commands.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ async function migrate ({ repoPath, migrations, to, dry, revertOk }) {
3636
migrations = require(migrations)
3737
}
3838

39+
if (!to) {
40+
to = migrator.getLatestMigrationVersion()
41+
}
42+
3943
const version = await repoVersion.getVersion(repoPath)
4044

4145
let action
@@ -57,7 +61,9 @@ async function migrate ({ repoPath, migrations, to, dry, revertOk }) {
5761
isDryRun: dry
5862
}
5963

60-
if (!to || (version <= to)) {
64+
if (version === to) {
65+
return chalk.yellow('Nothing to migrate! Versions matches')
66+
} else if (version < to) {
6167
await migrator.migrate(repoPath, options)
6268
} else if (revertOk) {
6369
await migrator.revert(repoPath, to, options)

src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async function migrate (path, { toVersion, ignoreLock = false, repoOptions, onPr
7575
}
7676

7777
if (currentVersion > toVersion) {
78-
log(`Current repo's version (${currentVersion} is higher then toVersion (${toVersion}), nothing to migrate.`)
78+
log(`Current repo's version (${currentVersion}) is higher then toVersion (${toVersion}), nothing to migrate.`)
7979
return
8080
}
8181

@@ -156,7 +156,7 @@ async function revert (path, toVersion, { ignoreLock = false, repoOptions, onPro
156156
}
157157

158158
if (currentVersion < toVersion) {
159-
log(`Current repo's version (${currentVersion} is lower then toVersion (${toVersion}), nothing to revert.`)
159+
log(`Current repo's version (${currentVersion}) is lower then toVersion (${toVersion}), nothing to revert.`)
160160
return
161161
}
162162

0 commit comments

Comments
 (0)