Skip to content

Commit 3bf8374

Browse files
committed
(patch): fixed database path resolution and added 1.0.0 release version
1 parent a288e39 commit 3bf8374

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "backuply",
3-
"version": "0.0.2",
3+
"version": "1.0.0",
44
"description": "A simple backup client for automating schedule file backups safely",
55
"exports": "./dist/app.js",
66
"types": "./dist/app.d.ts",

src/common/commands/parsing.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
import { readFileSync } from 'fs'
12
import yargs from 'yargs'
23
import { hideBin } from 'yargs/helpers'
34

5+
function _getPackageVersion(): string {
6+
const pkg = JSON.parse(readFileSync('../../../package.json').toString())
7+
8+
return pkg.version
9+
}
10+
411
// Handle parse args
512
export function parseArgs(): { [x: string]: unknown;
613
_: (string | number)[]; $0: string; } |
@@ -58,5 +65,6 @@ export function parseArgs(): { [x: string]: unknown;
5865
// Set general parse config
5966
return cmd.usage('Usage: $0 <command> [options...]')
6067
.demandCommand(1)
68+
.version(`backuply v${_getPackageVersion()}`)
6169
.argv
6270
}

src/lib/database.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { BackupRecord, RecordTable, RecordType } from '../common/types.js'
33
import { RecordNotFoundException } from '../common/exceptions.js'
44
import { AppConfig } from './configuration.js'
55
import { DB_KEY } from '../common/constants.js'
6+
import { resolve } from 'path/posix'
7+
import { cwd } from 'process'
68

79
export class DatabaseManager {
810
private static instance: DatabaseManager
@@ -19,7 +21,7 @@ export class DatabaseManager {
1921
if (error) {
2022
throw new Error(`Could not create database instance. Reason: ${error.message}`)
2123
}
22-
DatabaseManager.instance = new DatabaseManager(path ? path : value['path'].toString())
24+
DatabaseManager.instance = new DatabaseManager(path ? path : resolve(cwd(), value['path'].toString()))
2325
}
2426

2527
return DatabaseManager.instance

0 commit comments

Comments
 (0)