无法解析错误 - 出了什么问题?

时间:2016-04-19 13:45:19

标签: javascript shell parsing

这是“无法解析错误”的行 - > var label = package.getComment()&& package.getComment():'N / A'

剩下的代码......     var script ='/ home / paulomacedo / jd2 / JD_HOME / jdownloader-posttprocess.sh'

var path = package.getDownloadFolder() 
var name = package.getName() 
var label = package.getComment() && package.getComment() : 'N/A' 
var links = package.getDownloadLinks() ? package.getDownloadLinks() : []

function isReallyFinished() {
    for (var i = 0; i < links.length; i++) {
        if (links[i].getArchive() != null && links[i].getExtractionStatus() != "SUCCESSFUL" || !package.isFinished()) {
            return false
        }
    }
    return true
}

if (isReallyFinished()) {
    var command = [script, path, name, label, 'PACKAGE_FINISHED']
    log(command)
    log(callSync(command))
}

1 个答案:

答案 0 :(得分:1)

错误在于:

var label = package.getComment() && package.getComment() : 'N/A' 
//                                                       ^

您想要使用ternary operator

var label = package.getComment() ? package.getComment() : 'N/A' 

a && b || c

var label = package.getComment() && package.getComment() || 'N/A'