mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2026-04-28 11:17:38 +02:00
p2p fixes
This commit is contained in:
@@ -37,12 +37,16 @@ export default {
|
||||
renameFile: renameFile,
|
||||
deleteDir: deleteDir,
|
||||
formatBytes: formatBytes,
|
||||
getGitRevision: getGitRevision,
|
||||
getScriptVersion: getScriptVersion,
|
||||
}
|
||||
|
||||
import * as child_process from 'child_process'
|
||||
import fs from 'fs'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import logger from '../utils/logger'
|
||||
|
||||
import constants from '../constants.json'
|
||||
import { Request } from '../types/basicTypes'
|
||||
|
||||
interface URLFormatOptions {
|
||||
@@ -309,3 +313,29 @@ function formatBytes(number: number, unit: 'MB' | 'GB' = 'MB'): string {
|
||||
}
|
||||
return `${number} byte`
|
||||
}
|
||||
|
||||
function getGitRevision(dir: string): string {
|
||||
try {
|
||||
return child_process
|
||||
.execSync('git rev-parse HEAD', {
|
||||
cwd: dir,
|
||||
stdio: [0, 'pipe', null],
|
||||
})
|
||||
.toString()
|
||||
.trim()
|
||||
} catch (e) {
|
||||
return 'Failed to get revision'
|
||||
}
|
||||
}
|
||||
|
||||
function getScriptVersion(): string {
|
||||
const scriptContent = ReadFile(constants.moodleTestUserscriptPath)
|
||||
|
||||
let temp: string | string[] = scriptContent.split('\n').find((x) => {
|
||||
return x.includes('@version')
|
||||
})
|
||||
temp = temp.split(' ')
|
||||
temp = temp[temp.length - 1]
|
||||
|
||||
return temp
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user