<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for pug-load\index.js</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="../prettify.css" />
    <link rel="stylesheet" href="../base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type='text/css'>
        .coverage-summary .sorter {
            background-image: url(../sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class='wrapper'>
  <div class='pad1'>
    <h1>
      <a href="../index.html">all files</a> / <a href="index.html">pug-load/</a> index.js
    </h1>
    <div class='clearfix'>
      <div class='fl pad1y space-right2'>
        <span class="strong">91.23% </span>
        <span class="quiet">Statements</span>
        <span class='fraction'>52/57</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">86.49% </span>
        <span class="quiet">Branches</span>
        <span class='fraction'>32/37</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">100% </span>
        <span class="quiet">Functions</span>
        <span class='fraction'>8/8</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">91.23% </span>
        <span class="quiet">Lines</span>
        <span class='fraction'>52/57</span>
      </div>
      <div class='fl pad1y'>
        <span class="strong">5 statements, 5 branches</span>
        <span class="quiet">Ignored</span>  &nbsp;&nbsp;&nbsp;&nbsp;
      </div>
    </div>
  </div>
  <div class='status-line high'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">17×</span>
<span class="cline-any cline-yes">14×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">4×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">7×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">7×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">7×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">7×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">7×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">7×</span>
<span class="cline-any cline-yes">7×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
&nbsp;
var fs = require('fs');
var path = require('path');
var walk = require('pug-walk');
var assign = require('object-assign');
&nbsp;
module.exports = load;
function load(ast, options) {
  options = getOptions(options);
  // clone the ast
  ast = JSON.parse(JSON.stringify(ast));
  return walk(ast, function (node) {
    if (node.str === undefined) {
      if (node.type === 'Include' || node.type === 'RawInclude' || node.type === 'Extends') {
        var file = node.file;
        <span class="missing-if-branch" title="if path not taken" >I</span>if (file.type !== 'FileReference') {
<span class="cstat-no" title="statement not covered" >          throw new Error('Expected file.type to be "FileReference"');</span>
        }
        var path, str;
        try {
          path = options.resolve(file.path, file.filename, options);
          file.fullPath = path;
          str = options.read(path, options);
        } catch (ex) {
<span class="cstat-no" title="statement not covered" >          ex.message += '\n    at ' + node.filename + ' line ' + node.line;</span>
<span class="cstat-no" title="statement not covered" >          throw ex;</span>
        }
        file.str = str;
        if (node.type === 'Extends' || node.type === 'Include') {
          file.ast = load.string(str, assign({}, options, {
            filename: path
          }));
        }
      }
    }
  });
}
&nbsp;
load.string = function loadString(src, options) {
  options = assign(getOptions(options), {
    src: src
  });
  var tokens = options.lex(src, options);
  var ast = options.parse(tokens, options);
  return load(ast, options);
};
load.file = function loadFile(filename, options) {
  options = assign(getOptions(options), {
    filename: filename
  });
  var str = options.read(filename);
  return load.string(str, options);
}
&nbsp;
load.resolve = function resolve(filename, source, options) {
  filename = filename.trim();
  <span class="missing-if-branch" title="if path not taken" >I</span>if (filename[0] !== '/' &amp;&amp; !source)
<span class="cstat-no" title="statement not covered" >    throw new Error('the "filename" option is required to use includes and extends with "relative" paths');</span>
&nbsp;
  <span class="missing-if-branch" title="if path not taken" >I</span>if (filename[0] === '/' &amp;&amp; <span class="branch-1 cbranch-no" title="branch not covered" >!options.basedir)</span>
<span class="cstat-no" title="statement not covered" >    throw new Error('the "basedir" option is required to use includes and extends with "absolute" paths');</span>
&nbsp;
  filename = path.join(filename[0] === '/' ? <span class="branch-0 cbranch-no" title="branch not covered" >options.basedir </span>: path.dirname(source.trim()), filename);
&nbsp;
  return filename;
};
load.read = function read(filename, options) {
  return fs.readFileSync(filename, 'utf8');
};
&nbsp;
load.validateOptions = function validateOptions(options) {
  /* istanbul ignore if */
  <span class="skip-if-branch" title="if path not taken" >I</span>if (typeof options !== 'object') {
<span class="cstat-skip" title="statement not covered" >    throw new TypeError('options must be an object');</span>
  }
  /* istanbul ignore if */
  <span class="skip-if-branch" title="if path not taken" >I</span>if (typeof options.lex !== 'function') {
<span class="cstat-skip" title="statement not covered" >    throw new TypeError('options.lex must be a function');</span>
  }
  /* istanbul ignore if */
  <span class="skip-if-branch" title="if path not taken" >I</span>if (typeof options.parse !== 'function') {
<span class="cstat-skip" title="statement not covered" >    throw new TypeError('options.parse must be a function');</span>
  }
  /* istanbul ignore if */
  <span class="skip-if-branch" title="if path not taken" >I</span>if (options.resolve &amp;&amp; typeof options.resolve !== 'function') {
<span class="cstat-skip" title="statement not covered" >    throw new TypeError('options.resolve must be a function');</span>
  }
  /* istanbul ignore if */
  <span class="skip-if-branch" title="if path not taken" >I</span>if (options.read &amp;&amp; typeof options.read !== 'function') {
<span class="cstat-skip" title="statement not covered" >    throw new TypeError('options.read must be a function');</span>
  }
};
&nbsp;
function getOptions(options) {
  load.validateOptions(options);
  return assign({
    resolve: load.resolve,
    read: load.read
  }, options);
}
&nbsp;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
  Code coverage
  generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Wed Aug 24 2016 11:54:06 GMT-0700 (Pacific Daylight Time)
</div>
</div>
<script src="../prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="../sorter.js"></script>
</body>
</html>
