Skip to content

Commit 698f2ee

Browse files
committed
Add version infos to output
1 parent 7af008b commit 698f2ee

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/Backup.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class Backup {
5555
await this.registerCommands();
5656
await this.registerMenues();
5757
await this.createErrorDialog();
58+
await this.logVerisonInfos();
5859
await this.loadSettings();
5960
await this.startTimer();
6061
await this.upgradeBackupPluginVersion();
@@ -545,6 +546,14 @@ class Backup {
545546
);
546547
}
547548

549+
public async logVerisonInfos() {
550+
const joplinVersionInfo = await helper.joplinVersionInfo();
551+
const pluginVersion = await helper.getPluginVersion();
552+
this.log.verbose("Joplin Version: " + joplinVersionInfo.version);
553+
this.log.verbose("Node.JS Version: " + process.version);
554+
this.log.info("Plugin Version: " + pluginVersion);
555+
}
556+
548557
public async start(showDoneMsg: boolean = false) {
549558
// Prevent error message for empty profile on automatic backup
550559
// https://github.com/JackGruber/joplin-plugin-backup/issues/71
@@ -560,6 +569,7 @@ class Backup {
560569
await this.deleteLogFile();
561570
await this.fileLogging(true);
562571
this.log.info("Backup started");
572+
await this.logVerisonInfos();
563573

564574
await this.stopTimer();
565575

src/helper.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@ import { exec } from "child_process";
44
import { promisify } from "util";
55
import { copyFileSync } from "fs-extra";
66
import { moveSync } from "fs-extra";
7+
import * as fs from "fs-extra";
78

89
export namespace helper {
10+
export async function getPluginVersion(): Promise<string> {
11+
const installationDir = await joplin.plugins.installationDir();
12+
try {
13+
const manifest = JSON.parse(
14+
fs.readFileSync(path.join(installationDir, "manifest.json"), "utf8")
15+
);
16+
return manifest.version;
17+
} catch (error) {
18+
return "n/a";
19+
}
20+
}
21+
922
export async function validFileName(fileName: string) {
1023
var regChar = /[:*?"<>\/|\\]+/; // forbidden characters \ / : * ? " < > |
1124
var rexNames = /^(nul|prn|con|lpt[0-9]|com[0-9])(\.|$)/i; // forbidden file names

0 commit comments

Comments
 (0)