Skip to content

Commit 26648ae

Browse files
committed
use assert for coverage
1 parent f350699 commit 26648ae

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
var Promise = require('native-or-bluebird')
33
var resolve = require('path').resolve
44
var extname = require('path').extname
5+
var assert = require('assert')
56
var fs = require('fs')
67

78
Templation.engines = require('./engines')
@@ -23,8 +24,8 @@ function Templation(options) {
2324
}
2425

2526
Templation.prototype.use = function (ext, engine) {
27+
assert(engine, 'no engine defined')
2628
if (typeof ext !== 'string') throw new TypeError('each engine must map to an extension')
27-
if (!engine) throw new Error('no engine defined')
2829
if (typeof engine.compile !== 'function') throw new TypeError('each engine must define a .compile()')
2930
if (typeof engine.render !== 'function') throw new TypeError('each engine must define a .render()')
3031
this.engines[ext] = engine
@@ -43,7 +44,7 @@ Templation.prototype.render = function (name, options, fn) {
4344
return self._render(compiled.__templation_engine, compiled, options)
4445
})
4546
.then(validateOutput)
46-
47+
4748
if (typeof fn === 'function') {
4849
promise.then(function (out) {
4950
fn(null, out)
@@ -61,8 +62,7 @@ Templation.prototype._lookup = function (name) {
6162
var engine
6263

6364
if (ext) {
64-
engine = engines[ext]
65-
if (!engine) throw new Error('no view engine found for: ' + ext)
65+
assert(engine = engines[ext], 'no view engine found for: ' + ext)
6666
return [filename, engine]
6767
}
6868

0 commit comments

Comments
 (0)