Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
feat: fix db path resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
nduchak committed Aug 18, 2020
1 parent 06ff77a commit f2e9c51
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cli/db-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,24 @@ export default class DbMigrationCommand extends BaseCLICommand {

protected resolveDbPath (db: string): string {
if (!db) {
return path.resolve(this.config.dataDir, config.get<string>('db'))
return `sqlite://${path.resolve(this.config.dataDir, config.get<string>('db'))}`
}

const parsed = path.parse(db)

// File name
if (!parsed.dir) {
return path.resolve(
return `sqlite://${path.resolve(
this.config.dataDir,
parsed.ext
? db
: `${parsed.base}.sqlite`
)
)}`
} else {
if (db[db.length - 1] === '/') {
throw new Error('Path should include the file name')
}
return path.resolve(`${db}${parsed.ext ? '' : '.sqlite'}`)
return `sqlite://${path.resolve(`${db}${parsed.ext ? '' : '.sqlite'}`)}`
}
}

Expand Down Expand Up @@ -125,7 +125,7 @@ export default class DbMigrationCommand extends BaseCLICommand {
const parsedFlags = originalFlags as OutputFlags<typeof DbMigrationCommand.flags>

if (parsedFlags.db) {
config.util.extendDeep(config, { db: `sqlite://${this.resolveDbPath(parsedFlags.db)}` })
config.util.extendDeep(config, { db: this.resolveDbPath(parsedFlags.db) })
}

if (parsedFlags.generate) {
Expand Down

0 comments on commit f2e9c51

Please sign in to comment.