2016-04-19 42 views
0

這與 「無法解析錯誤」 的線 - >無功標籤= package.getComment()& & package.getComment(): 'N/A'解析錯誤失敗 - 出現了什麼問題?

的代碼的其餘部分... VAR腳本= '/home/paulomacedo/jd2/JD_HOME/jdownloader-postprocess.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)) 
} 
+0

也許你要問在代碼審查這個問題:http://codereview.stackexchange.com/ –

+0

@SuperPeanut代碼審查是詢問[最佳實踐等上** working code **。](http://codereview.stackexchange.com/help/on-topic) –

+0

@MikeC我很抱歉... –

回答

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' 
相關問題