0
我想要的東西應該做我的工作之前完成:可以nodejs阻止,直到完成任何事情?
registerTools();
// this should do until registerTools is done!
processJob();
這裏是registerTools
function registerTools() {
extractors = fs.readdirSync(extractorPath).filter(function(extractor) {
return extractor !== "temp";
});
totalExtractors = extractors.length;
extractors.map(function(item) {
var fullExtractorPath = path.join(extractorPath, item);
return require(fullExtractorPath);
}).forEach(function(extractor) {
if (extractor.test) {
testExtractor(extractor);
} else {
satisfiedExtractors++;
registerExtractor(extractor);
}
});
}
var registerExtractor = function(extractor) {
if (extractor.extensions) {
extractor.extensions.forEach(function(ext) {
extensionExtractors[ext] = extractor.extract;
});
}
};
你沒有做任何異步工作。所以它會默認阻止。 – thefourtheye