Clean Sonar findings: merge RUNs, drop commented code, update node imports
All checks were successful
build-and-push / lint (push) Successful in 4s
build-and-push / sonar (push) Successful in 11s
build-and-push / docker (push) Successful in 1m13s

This commit is contained in:
nocci 2025-12-30 15:39:11 +00:00
parent 37ffd09545
commit 405e801851
7 changed files with 44 additions and 72 deletions

View file

@ -1,6 +1,4 @@
// check if running the latest version
import { log } from 'console';
import { log } from 'node:console';
import { execFile } from 'node:child_process';
const gitBin = process.env.GIT_BIN || '/usr/bin/git';
@ -20,10 +18,7 @@ const runGit = (...args) => new Promise((resolve, reject) => {
});
});
// const git_main = () => readFileSync('.git/refs/heads/main').toString().trim();
let sha, date;
// if (existsSync('/.dockerenv')) { // did not work
if (process.env.NOVNC_PORT) {
log('Running inside Docker.');
['COMMIT', 'BRANCH', 'NOW'].forEach(v => log(` ${v}:`, process.env[v]));
@ -33,22 +28,13 @@ if (process.env.NOVNC_PORT) {
log('Not running inside Docker.');
sha = await runGit('rev-parse', 'HEAD');
date = await runGit('show', '-s', '--format=%cD'); // same as format as `date -R` (RFC2822)
// date = await execp('git show -s --format=%ch'); // %ch is same as --date=human (short/relative)
}
const gh = await (await fetch('https://api.github.com/repos/vogler/free-games-claimer/commits/main', {
// headers: { accept: 'application/vnd.github.VERSION.sha' }
})).json();
// log(gh);
const gh = await (await fetch('https://api.github.com/repos/vogler/free-games-claimer/commits/main')).json();
log('Local commit:', sha, new Date(date));
log('Online commit:', gh.sha, new Date(gh.commit.committer.date));
// git describe --all --long --dirty
// --> heads/main-0-gdee47d2-dirty
// git describe --tags --long --dirty
// --> v1.7-35-gdee47d2-dirty
if (sha == gh.sha) {
log('Running the latest version!');
} else {