Add display version #280

This commit is contained in:
SillyLossy
2023-05-12 11:30:30 +03:00
parent afa7035632
commit d963d79d44
4 changed files with 29 additions and 4 deletions

View File

@@ -308,7 +308,7 @@ app.get('/deviceinfo', function (request, response) {
return response.send(deviceInfo);
});
app.get('/version', function (_, response) {
let pkgVersion, gitRevision;
let pkgVersion, gitRevision, gitBranch;
try {
const pkgJson = require('./package.json');
pkgVersion = pkgJson.version;
@@ -316,13 +316,18 @@ app.get('/version', function (_, response) {
gitRevision = require('child_process')
.execSync('git rev-parse --short HEAD', { cwd: __dirname })
.toString().trim();
gitBranch = require('child_process')
.execSync('git rev-parse --abbrev-ref HEAD', { cwd: __dirname })
.toString().trim();
}
}
catch {
// suppress exception
}
finally {
response.send(`SillyTavern:${gitRevision || pkgVersion}:Cohee#1207`)
const agent = `SillyTavern:${gitRevision || pkgVersion}:Cohee#1207`;
response.send({ agent, pkgVersion, gitRevision, gitBranch });
}
})