Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var fs = require('fs');
var path = require('path');
var less = require('less');
var staticModule = require('static-module');
var through = require('through2');
var savedValue;
less.functions.functionRegistry.add('__varlessifySaveValue', function (value) {
savedValue = value;
return value;
});
module.exports = function (file, opts) {
if (/\.json$/.test(file)) return through();
var parseCache = {};
var vars = {
__filename: file,
__dirname: path.dirname(file)
};
var sm = staticModule({
varless: { get: varless }
}, {vars: vars});
return sm;
Object.keys( userFns ).forEach( function ( name ) {
less.functions.functionRegistry.add( name.toLowerCase(), function () {
var res = userFns[ name ].apply( less, arguments );
return typeOf( res ) === 'object' ? res : new less.tree.Anonymous( res );
} );
} );
Object.keys(options.customFunctions).forEach(function(name) {
less.functions.functionRegistry.add(name.toLowerCase(), function() {
var args = [].slice.call(arguments);
args.unshift(less);
var res = options.customFunctions[name].apply(this, args);
return typeof res === 'object' ? res : new less.tree.Anonymous(res);
});
});
}
Object.keys(options.customFunctions).forEach(function(name) {
less.functions.functionRegistry.add(name.toLowerCase(), function() {
var args = [].slice.call(arguments);
args.unshift(less);
var res = options.customFunctions[name].apply(this, args);
return typeof res === 'object' ? res : new less.tree.Anonymous(res);
});
});
}
Object.keys(options.customFunctions).forEach(function(name) {
less.functions.functionRegistry.add(name.toLowerCase(), function() {
var args = [].slice.call(arguments);
args.unshift(less);
var res = options.customFunctions[name].apply(this, args);
return typeof res === 'object' ? res : new less.tree.Anonymous(res);
});
});
}
Object.keys(options.customFunctions).forEach(function(name) {
less.functions.functionRegistry.add(name.toLowerCase(), function() {
var args = [].slice.call(arguments);
args.unshift(less);
var res = options.customFunctions[name].apply(this, args);
return typeof res === 'object' ? res : new less.tree.Anonymous(res);
});
});
}