Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
err.message += ':\n' + err.extract.join('\n');
} else {
// Ensure message ends with a dot.
if (!/\.$/.test(err.message)) { err.message += '.'; }
}
if (err.filename === 'input') {
err.filename = filename;
}
return err;
}
var parseOptions = {
paths: [Path.dirname(filename)]//,
// filename: filename
},
parser = new less.Parser(parseOptions),
results = [];
parser.parse(body, function (err, tree) {
if (err) {
return callback(undefined, [prepareLessError(err)]);
}
try {
// Compiling to CSS will throw in case of undefined @variables etc.:
tree.toCSS();
} catch (e) {
return callback(undefined, [prepareLessError(e)]);
}
return callback(undefined, []);
});
Site.prototype._compile_templates = function(){
// var templates = this.app.params.templates;
//
// for ( var template in templates ) {
// var file = fs.readFileSync( path.join( this.app.base_dir, template ), 'utf8' );
// var compiled = this.dust.compile( file, path.basename( template, '.html' ) );
// var file_path = path.join( this.app.base_dir, templates[ template ], path.basename( template, '.html' ) + '.js' );
// if ( fs.existsSync( file_path ) ) fs.unlinkSync( file_path );
// var fd = fs.openSync( file_path, 'a', 0666 );
// fs.writeSync( fd, compiled, null, 'utf8' );
// fs.closeSync( fd );
// }
var style = fs.readFileSync( path.join( this.app.base_dir, 'static/css/style.less' ), 'utf8' );
var parser = new less.Parser({
paths: [ path.join( this.app.base_dir, 'node_modules/twitter-bootstrap/less/' ) ]//, // Specify search paths for @import directives
// filename: 'style.less' // Specify a filename, for better error messages
});
var self = this;
parser.parse( style, function (e, tree) {
var css = tree.toCSS({ compress: true }); // Minify CSS output
var css_file = path.join( self.app.base_dir, 'static/css/style.css' );
if ( fs.existsSync( css_file ) ) fs.unlinkSync( css_file );
var fd = fs.openSync( css_file, 'a', 0666 );
fs.writeSync( fd, css, null, 'utf8' );
fs.closeSync( fd );
});
}
fs.readFile(srcPath, function(err, data){
if(err) return callback(err)
var dirs = [
path.dirname(srcPath),
path.dirname(path.resolve(projectPath, "public"))
]
var parser = new(less.Parser)({
paths: dirs, // Specify search paths for @import directives
filename: file // Specify a filename, for better error messages
})
parser.parse(data.toString(), function (err, tree) {
try{
var css = tree.toCSS({ compress: true })
callback(e, css)
}catch(e){
callback(e)
}
})
})
}
high.util.loopOverFolders([high.config._less_path], function(file_name, root_path) {
// LESS
if(file_name.match(/.less$/)){
var parser = new(less.Parser)({
paths: [high.config._less_path], // Specify search paths for @import directives
filename: file_name // Specify a filename, for better error messages
})
var file_contents = fs.readFileSync(root_path + file_name, {'encoding': 'utf8'});
parser.parse(file_contents, function(err, tree) {
if(err) {
log(err)
return
}
var less_config,
compiled_file_contents;
if(high.config.env === 'dev') {
less_config = high.config.less.dev;
} else {
less_config = high.config.less.prod;
grunt.fail.warn(wrapError(e, 'Generating @import paths failed.'));
}
}
if (typeof options.sourceMapBasepath === 'function') {
try {
options.sourceMapBasepath = options.sourceMapBasepath(srcFile);
} catch (e) {
grunt.fail.warn(wrapError(e, 'Generating sourceMapBasepath failed.'));
}
}
var css;
var srcCode = grunt.file.read(srcFile);
var parser = new less.Parser(_.pick(options, lessOptions.parse));
var additionalData = {
banner: options.banner
};
// Equivalent to --modify-vars option.
// Properties under options.modifyVars are appended as less variables
// to override global variables.
var modifyVarsOutput = parseVariableOptions(options['modifyVars']);
if (modifyVarsOutput) {
srcCode += '\n';
srcCode += modifyVarsOutput;
}
parser.parse(srcCode, function(parse_err, tree) {
if (parse_err) {
lessError(parse_err, srcFile);
}
}
fs.outputFile(output + '.map', JSON.stringify(data), function(err) {
if (err) callback(err);
});
} catch (e) {}
}
};
var parser = new(less.Parser)({
paths: [path.dirname(input)],
filename: input
});
fs.readFile(input, 'utf8', function(err, data) {
if (err) return callback(new Error('Unable to read source file\n' + err.message));
parser.parse(data, function(err, tree) {
if (err) return callback(new Error(err.message + "\n" + err.filename + ' line ' + err.line));
var css;
try {
/*!
* cube: lib/csscombine.js
* Authors : Fish (https://github.com/fishbar)
* Create : 2014-04-18 15:32:20
* CopyRight 2014 (c) Fish And Other Contributors
*/
var path = require('path');
var css = require('clean-css');
var less = require('less');
var sass = require('./sass');
var stylus = require('stylus');
var fs = require('fs');
var lessParser = new(less.Parser)({
paths: [process.cwd()]
});
exports.transferFile = function(file, compress) {
var code;
try {
code = fs.readFileSync(file, 'utf8').toString();
} catch (e) {
e.message += 'module not found "' + file + '"';
throw e;
}
var ext = path.extname(file);
try {
switch (ext) {
case '.css':
code = this.transferCss(code, compress);
var compileLess = function(srcFile, options, callback) {
options = grunt.util._.extend({filename: srcFile}, options);
options.paths = options.paths || [path.dirname(srcFile)];
var css;
var srcCode = grunt.file.read(srcFile);
var parser = new less.Parser(grunt.util._.pick(options, lessOptions.parse));
parser.parse(srcCode, function(parse_err, tree) {
if (parse_err) {
lessError(parse_err);
callback('',true);
}
try {
css = tree.toCSS(grunt.util._.pick(options, lessOptions.render));
callback(css, null);
} catch (e) {
lessError(e);
callback(css, true);
}
});
};
function parseLess (callback) {
var stylesheet = fs.readFileSync(config.reportLessFile, {encoding: 'utf8'});
var parser = new(less.Parser)({
paths: [config.stylesDir, config.bsLessDir],
});
parser.parse(stylesheet, function(err, tree) {
if (err) callback(err);
var outCss = tree.toCSS({
compress: true
});
callback(null, outCss);
});
}
gruntConfig.less = gruntConfig.less || {};
gruntConfig.less[name] = gruntConfig.less[name] || {};
gruntConfig.less[name].files = gruntConfig.less[name].files || {};
gruntConfig.less[name].files[bundleOptions.path + name + '.min.css'] = 'less/' + name + '.less';
gruntConfig.less[name].options = {
sourceMap: true,
sourceMapFilename: bundleOptions.path + name + '.min.css.map'
};
gruntConfig.watch = gruntConfig.watch || {};
gruntConfig.watch['less-' + name] = gruntConfig.watch['less-' + name] || {
files: [ 'less/' + name + '.less' ],
tasks: [ 'less:' + name ]
};
var parser = new(less.Parser)({ syncImport: true, paths: ['less'], filename: name + '.less' }),
bundleFile = fs.readFileSync('less/' + name + '.less', { encoding: 'utf-8' });
parser.parse(bundleFile, function() {
for(var file in parser.imports.files) {
gruntConfig.watch['less-' + name].files.push(file);
}
});
}
},