1
0
Fork 0
peertube/shared/extra-utils/cli/cli-command.ts
kontrollanten e1ab52d7ec
Add migrate-to-object-storage script (#4481)
* add migrate-to-object-storage-script

closes #4467

* add migrate-to-unique-playlist-filenames script

* fix(migrate-to-unique-playlist-filenames): update master/segments256

run updateMasterHLSPlaylist and updateSha256VODSegments after
file rename.

* Improve move to object storage scripts

* PR remarks

Co-authored-by: Chocobozzz <me@florianbigard.com>
2021-11-09 11:05:35 +01:00

27 lines
684 B
TypeScript

import { exec } from 'child_process'
import { AbstractCommand } from '../shared'
export class CLICommand extends AbstractCommand {
static exec (command: string) {
return new Promise<string>((res, rej) => {
exec(command, (err, stdout, _stderr) => {
if (err) return rej(err)
return res(stdout)
})
})
}
getEnv () {
return `NODE_ENV=test NODE_APP_INSTANCE=${this.server.internalServerNumber}`
}
async execWithEnv (command: string, configOverride?: any) {
const prefix = configOverride
? `NODE_CONFIG='${JSON.stringify(configOverride)}'`
: ''
return CLICommand.exec(`${prefix} ${this.getEnv()} ${command}`)
}
}