diff --git a/citeproc-wrapper.js b/citeproc-wrapper.js index 76f2d94..435b2d8 100644 --- a/citeproc-wrapper.js +++ b/citeproc-wrapper.js @@ -7,11 +7,13 @@ function Citeproc (citations, styleLocation, localeLocation, done) { this.construct = function () { var self = this; - self.loadStyle(styleLocation, function () { - self.loadLocale(localeLocation, function () { + self.loadStyle(styleLocation, function (err) { + if (err) return done(err); + self.loadLocale(localeLocation, function (err) { + if (err) return done(err); self.setupSys(); citeproc = new CSL.Engine(sys, style); - done(citeproc); + done(null, citeproc); }); }); } diff --git a/test/test.js b/test/test.js index 3b63adb..70942bb 100644 --- a/test/test.js +++ b/test/test.js @@ -10,11 +10,11 @@ describe('citeproc-js', function () { var style = './styles/chicago-fullnote-bibliography.csl'; var locale = './locales/locales-nb-NO.xml'; - var cite = new Citeproc(citations, style, locale, function (citeproc) { + var cite = new Citeproc(citations, style, locale, function (err, citeproc) { citeproc.updateItems(Object.keys(citations)); var bibliography = citeproc.makeBibliography(); console.log(bibliography); - done(); + done(err); }); }); });