Skip to content

Commit

Permalink
fix: switched eval to new Function
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Jan 24, 2019
1 parent b9ea683 commit 093b54c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint no-eval: 0 */
const { spawn } = require('child_process');
const fs = require('fs');
const path = require('path');
Expand Down Expand Up @@ -117,7 +116,12 @@ class CachePugTemplates {
(function() {
try {
tmpl = tmpl.trim();
if (tmpl) pug.cache[filename] = eval(`(${tmpl})`);
if (tmpl) {
tmpl = tmpl.replace('function template(locals) {', '');
tmpl = tmpl.replace('return pug_html;}', 'return pug_html;');
// eslint-disable-next-line no-new-func
pug.cache[filename] = new Function('locals', tmpl);
}
} catch (err) {
err.message = `${filename}: ${err.message}`;
console.error(err);
Expand Down

0 comments on commit 093b54c

Please sign in to comment.