async function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
const allowed = await isSignupAllowed()
const allowedForCurrentIP = isSignupAllowedForCurrentIP(req.ip)
- serverCommit = (serverCommit) ? serverCommit : getVersion()
+ serverCommit = (serverCommit) ? serverCommit : await getVersion()
if (serverCommit === packageJSON.version) serverCommit = ''
const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
import { createHash, pseudoRandomBytes } from 'crypto'
import { isAbsolute, join } from 'path'
import * as pem from 'pem'
-import * as rimraf from 'rimraf'
import { URL } from 'url'
import { truncate } from 'lodash'
+import { exec } from 'child_process'
const timeTable = {
ms: 1,
const bcryptGenSaltPromise = promisify1<number, string>(bcrypt.genSalt)
const bcryptHashPromise = promisify2<any, string | number, string>(bcrypt.hash)
const createTorrentPromise = promisify2<string, any, any>(createTorrent)
+const execPromise2 = promisify2<string, any, string>(exec)
+const execPromise = promisify1<string, string>(exec)
// ---------------------------------------------------------------------------
bcryptComparePromise,
bcryptGenSaltPromise,
bcryptHashPromise,
- createTorrentPromise
+ createTorrentPromise,
+ execPromise2,
+ execPromise
}
import { ResultList } from '../../shared'
import { CONFIG } from '../initializers'
import { ApplicationModel } from '../models/application/application'
-import { pseudoRandomBytesPromise, sha256 } from './core-utils'
+import { execPromise, execPromise2, pseudoRandomBytesPromise, sha256 } from './core-utils'
import { logger } from './logger'
import { join } from 'path'
import { Instance as ParseTorrent } from 'parse-torrent'
return sha256(originalName) + '.torrent'
}
-function getVersion () {
- const tag = require('child_process')
- .execSync('[[ ! -d .git ]] || git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || true', { stdio: [0,1,2] })
- if (tag) return tag.replace(/^v/, '')
-
- const version = require('child_process')
- .execSync('[[ ! -d .git ]] || git rev-parse --short HEAD').toString().trim()
- if (version) return version
+async function getVersion () {
+ try {
+ const tag = await execPromise2(
+ '[ ! -d .git ] || git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || true',
+ { stdio: [ 0, 1, 2 ] }
+ )
+
+ if (tag) return tag.replace(/^v/, '')
+ } catch (err) {
+ logger.debug('Cannot get version from git tags.', { err })
+ }
+
+ try {
+ const version = await execPromise('[ ! -d .git ] || git rev-parse --short HEAD')
+
+ if (version) return version.toString().trim()
+ } catch (err) {
+ logger.debug('Cannot get version from git HEAD.', { err })
+ }
return require('../../../package.json').version
}
const config = require('application-config')('PeerTube/CLI')
const netrc = require('netrc-parser').default
-import { getVersion } from '../helpers/utils'
-const version = getVersion
+const version = require('../../../package.json').version
let settings = {
remotes: [],
} from './cli'
program
- .version(version(), '-v, --version')
+ .version(version, '-v, --version')
.usage('[command] [options]')
/* Subcommands automatically loaded in the directory and beginning by peertube-* */