-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
71 lines (51 loc) · 2.12 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const path = require('path')
const nconf = require('nconf')
const os = require('os')
const process = require('process')
const fs = require('fs')
const conffilePath = path.join(os.homedir(), '.tutsplus-video-tools.json')
nconf
.env()
.file({file: conffilePath})
// ffmpegBinPath: 'C:\\Users\\Adam\\bin\\ffmpeg-20150913-git-d13a2df-win64-static\\bin'
let ffmpegBinPath = nconf.get('ffmpegBinPath')
let ffmpegExtension = ''
if (os.platform() == 'win32')
ffmpegExtension = '.exe'
let config = {}
config.ffmpegPath = path.join(ffmpegBinPath , 'ffmpeg'+ffmpegExtension)
config.ffprobePath = path.join(ffmpegBinPath , 'ffprobe'+ffmpegExtension)
config.requireFfmpeg = function () {
if (ffmpegBinPath == undefined) {
console.log(`Error: No ffmpeg bin path was specified. Set this as an as an environment variable, or in the ${conffilePath} config file`)
process.exit(2)
}
//test that the ffmpeg and ffprobe files exist?
try {
fs.accessSync(config.ffmpegPath, fs.X_OK)
}
catch (ex) {
console.log(`Error: No ffmpeg binary was found in the specified ffmpeg bin path ${config.ffmpegPath} was specified. Set this as an as an environment variable, or in the ${conffilePath} config file`)
process.exit(2)
}
try {
fs.accessSync(config.ffprobePath, fs.X_OK)
}
catch (ex) {
console.log(`Error: No ffprobe binary was found in the specified ffmpeg bin path ${config.ffprobePath} was specified. Set this as an as an environment variable, or in the ${conffilePath} config file`)
process.exit(2)
}
}
config.auphonicUsername = nconf.get('auphonicUsername')
config.auphonicPassword = nconf.get('auphonicPassword')
config.requireAuphonicUser = function () {
if (config.auphonicUsername == undefined) {
console.log(`Error: No Auphonic username was specified. Set this as an as an environment variable, or in the ${conffilePath} config file`)
process.exit(2)
}
if (config.auphonicPassword == undefined) {
console.log(`Error: No Auphonic password was specified. Set this as an as an environment variable, or in the ${conffilePath} config file`)
process.exit(2)
}
}
module.exports = config