我正在尝试迭代从promise解析的数组,但是它看起来为空,尽管当我将其登录到控制台时我可以看到项目!
我用咖啡脚本
这是发生问题的功能
folderPath = getUsersHomeFolder()
getFilesInFolder folderPath
.then (files) =>
inspectAndDescribeFiles folderPath, files
.then (results) =>
// hers the problem happen
displayFile result for result in results
.catch (err) =>
alert 'Sorry, we can not read your files'
console.log '--- Error in get users files', err
这是inspectAndDescribeFile()函数
inspectAndDescribeFiles = (folderPath, files) ->
new Promise (resolve, reject) =>
results = []
for file in files
resolveFilePath = path.resolve folderPath, file
inspectAndDescribeFile resolveFilePath
.then (result) ->
results.push result
.catch (err) ->
results.push err
resolve results