私は以下の機能に少し問題があります。 Promise.mapは、Folder.createが終了して次の値を反復するのを待つことはありません。Promiseに関する問題
Promise.map(name, function(na){
return fs.stat(na.url, function(err, stats){
if (typeof stats === 'undefined'){
console.log("file doesn't exist");
return Folder.create(na).then(function(fd){
return mkdirp(root + product.url).then(function(){
console.log("Folder Created");
return null;
});
}, function(err){
console.log(err);
return reject({message: "Error when creating the folder"});
});
}
});
}).then(function(){
console.log('Iteration Done');
return resolve({message: "Folder Created!"});
});
// I GOT :
//file doesn't exist
//file doesn't exist
//file doesn't exist
//Iteration Done
//file doesn't exist
//file doesn't exist
//file doesn't exist
//Iteration Done
//Folder Created
//Folder Created
//Folder Created
//Folder Created
//Folder Created
//Folder Created
'if(typeof stats === 'undefined'){'? – Ioan
残念ながらいいえ、何も変わりません – musecz