jsoverson / preprocess

Preprocess HTML, JavaScript, and other files with directives based off custom or ENV configuration
Other
366 stars 80 forks source link

Undefined variables resolve as undefined #112

Closed morty closed 4 years ago

morty commented 8 years ago

In the README one of the the examples is:

var fingerprint = '<!-- @echo COMMIT_HASH -->' || 'DEFAULT';

When COMMIT_HASH is set to 0xDEADBEEF it should process to

var fingerprint = '0xDEADBEEF' || 'DEFAULT';

and when COMMIT_HASH is unset it should process to:

var fingerprint = '' || 'DEFAULT';

However when I try this I get

var fingerprint = 'undefined' || 'DEFAULT';

which does not do as expected.

The code I have been running is:

var pp = require('preprocess');

var text = "var fingerprint = '<!-- @echo COMMIT_HASH -->' || 'DEFAULT';";

console.log(pp.preprocess(text, {}, {type: 'html'}));

I am using preprocess 3.1.0 have tried nodejs versions v4.2.6 and v6.2.1.