diff --git a/lib/consolidate.js b/lib/consolidate.js index b2deb65..37386bf 100644 --- a/lib/consolidate.js +++ b/lib/consolidate.js @@ -540,7 +540,18 @@ exports.swig = fromStringRenderer('swig'); exports.swig.render = function(str, options, fn){ return promisify(fn, function(fn) { - var engine = requires.swig || (requires.swig = require('swig-templates')); + var engine = requires.swig; + if (!engine) { + try { + engine = requires.swig = require('swig'); + } catch (err) { + try { + engine = requires.swig = require('swig-templates'); + } catch (otherError) { + throw err; + } + } + } try { if(options.cache === true) options.cache = 'memory';