How to use the less.writeError function in less

To help you get started, we’ve selected a few less examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ibm-js / delite / themes / utils / compile.js View on Github external
parser.parse(lessContent, function (error, tree) {
		if (error) {
			less.writeError(error);
			process.exit(1);
		}

		// Get output CSS
		var outputText = tree.toCSS({compress: false});

		// If the caller asked to output an AMD module rather than a plain CSS file, add define() wrapper around CSS.
		// Assumes no single quotes or other weird characters, although double quotes for url("...") are OK.
		if (/\.js$/.test(outputFile)) {
			outputText = "define(function(){ return '\\\n" + outputText.replace(/\n/mg, "\\\n") + "'; } );\n";
		}

		// Now write out that CSS as an AMD module
		console.log("writing:", outputFile);
		var fd = fs.openSync(outputFile, "w");
		fs.write(fd, outputText, 0, "utf-8", function (f) {
github gdupont / less-monitor / lib / app.js View on Github external
this.emit( 'parseError', file, output );
							less.writeError( err, { color: true } );
							this.parsePending--;

						} else {

							var css,
								parseError = false;
							// Process less tree to css
							try {
								css = tree.toCSS({
									compress: this.options.compress
								});
							} catch ( e ) {
								this.emit( 'parseError', file, output );
								less.writeError( e, { color: true } );
								this.parsePending--;
								parseError = true;
							}
							var outputPath = this.getOuputPath(file, output);
							// Write the output file
							if ( !parseError ) {
								fs.writeFile( this.getAbsolutePath( outputPath ), css, "utf8", function( err ) {

									if ( err ) {
										this.emit( 'error', { message: 'Could not write file "' + outputPath + '"' } );
									} else {
										pending.erase( file );
										this.emit( 'parseComplete', file, outputPath, pending.length === 0 );
									}

									if ( --this.parsePending === 0 ) {
github toogle / express-less / lib / express-less.js View on Github external
less.render(data.toString('utf8'), opts, function(err, output) {
                if (err) {
                    if (options.debug) {
                        less.writeError(err);
                    }

                    return res.sendStatus(500);
                }

                // Store in cache
                if (options.cache) {
                    cache[src] = output.css;
                }

                res.set('Content-Type', 'text/css');
                res.send(output.css);
            });
        });
github mayflower / PHProjekt / phprojekt / htdocs / dojo / release / dojo / dijit / themes / claro / compile.js View on Github external
lessFiles.forEach(function(a){console.log("=== "+a);fs.readFile(a,"utf-8",function(b,c){b&&(console.error("lessc: "+b.message),process.exit(1));(new less.Parser({paths:[path.dirname(a)],optimization:options.optimization,filename:a})).parse(c,function(b,c){if(b)less.writeError(b,options),process.exit(1);else try{var d=c.toCSS({compress:options.compress}),e=a.replace(".less",".css");fd=fs.openSync(e,"w");fs.writeSync(fd,d,0,"utf8")}catch(f){less.writeError(f,options),process.exit(2)}})})});
github dojo / dojox / mobile / themes / utils / compile.js View on Github external
parser.parse(lessContent, function(error, tree){
		if(error){
			less.writeError(error);
			process.exit(1);
		}
		var fd = fs.openSync(outputFile, "w");
		
		fs.write(fd, tree.toCSS({compress: false}).replace(/\n/g, "\r\n"), 0, "utf-8", function(f){
			fs.close(fd);
			console.log("writing:", outputFile);
			endProcess();
		});
	});
}
github alohaeditor / Aloha-Editor / build / build.js View on Github external
new(less.Parser)(options).parse(data, function (err, tree) {
					if (err) {
							less.writeError(err, options);
							process.exit(1);
					} else {
							try {
									css = tree.toCSS({ compress: 1 });
									fs.writeFileSync(cssPath,css);
							} catch (e) {
									less.writeError(e, options);
									process.exit(2);
							}
					}
			});
github garden20 / baseline-garden-app / packages / less-precompiler / build / compile.js View on Github external
parser.parse(data, function (err, root) {
                    if (err) {
                        less.writeError(err, options);
                        return callback(err);
                    }
                    try {
                        callback(null, root.toCSS(options));
                    }
                    catch (e) {
                        less.writeError(e, options);
                        callback(e);
                    }
                });
            }
github jgreene / watch-less / cli.js View on Github external
}, function(error) {
                less.writeError(error, options);
            });
    };