jsoverson / preprocess

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

// @endif outputs whatever is behind the @endif token #103

Closed doberkofler closed 3 years ago

doberkofler commented 8 years ago

When preprocessing the following code without the DEBUG environment variable set:

'use strict';
var pp = require('preprocess');
var text = '//start\n// @ifdef DEBUG\nvar some;\n// @endif DEBUG\n//end';
console.log(pp.preprocess(text, {}, {type: 'js'}));

you would imagine, that the //start and //endlines will be returned but instead the following text will be returned:

//start
DEBUG
//end

Unfortunately preprocess will output whatever text is behind the @endif token and this seems very wrong to me.

kajmagnus commented 5 years ago

I break out \nvar some;\n// to a separate variable, and wrap it in @ifdef to deal with that. Agree that it's surprising behavior.