mirror of https://github.com/thumbsup/thumbsup
fix(cli): show an error on startup if one of the binary dependencies is missing
Closes #95pull/99/head
parent
424d2c8b8b
commit
a5a75b81ad
@ -0,0 +1,31 @@
|
||||
const chalk = require('chalk')
|
||||
const commandExists = require('command-exists')
|
||||
|
||||
const COMMANDS = {
|
||||
'gm': 'http://www.graphicsmagick.org',
|
||||
'exiftool': 'https://www.sno.phy.queensu.ca/~phil/exiftool',
|
||||
'ffmpeg': 'https://www.ffmpeg.org'
|
||||
}
|
||||
|
||||
exports.verify = function () {
|
||||
const missing = Object.keys(COMMANDS).reduce(addToArrayIfMissing, [])
|
||||
if (missing.length > 0) {
|
||||
const list = missing.map(nameAndURL).join('\n')
|
||||
return `The following programs are required to run thumbsup:\n
|
||||
${list}\n
|
||||
Please make sure they are installed and available in the system path.`
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function addToArrayIfMissing (acc, cmd) {
|
||||
if (!commandExists.sync(cmd)) {
|
||||
acc.push(cmd)
|
||||
}
|
||||
return acc
|
||||
}
|
||||
|
||||
function nameAndURL (cmd) {
|
||||
const url = chalk.green(COMMANDS[cmd])
|
||||
return `- ${cmd} (${url})`
|
||||
}
|
Loading…
Reference in New Issue