Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Commit

Permalink
Fixed a bug where the parser breaks when noticing errors in imported …
Browse files Browse the repository at this point in the history
…less

files.
  • Loading branch information
Christian Engel committed Dec 15, 2011
1 parent 7187fc7 commit 23421fe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -29,6 +29,7 @@ v 1.3
- fixed a bug where urls in stylesheets got messed up with random "app://com.wearekiss.simpless.open/" insertions.
- included LESS parser 1.1.6
- addded support for backwards @import. Compilation is triggered, if imported files are changed.
- capturing compiling errors in imported files now.


v 1.2
Expand Down
19 changes: 13 additions & 6 deletions Resources/js/app.js
Expand Up @@ -567,6 +567,7 @@ var app = {
var input = indexed_less_file_object.infile;
var output = indexed_less_file_object.outfile;
var lesscode = '';
app.debug('Loading source');
if (input.size()) {
lesscode = input.open().read().toString();
}
Expand All @@ -584,21 +585,24 @@ var app = {
app.compiling_file = indexed_less_file_object;
app.import_error = null;

indexed_less_file_object.compile_status = 0;
indexed_less_file_object.compiler_error = '';

app.debug('Passing Data to the parser (Data size:'+lesscode.length+')');
try {
app.parser.parse(lesscode, function(err, tree) {
app.debug('Parser returned result');
if (err) {
app.debug('Result was an error');
indexed_less_file_object.compiler_error = err.message.replace(/(on line \d+)/, '<span style="font-weight: bold;">$1</span>');
indexed_less_file_object.compile_status = 2;
app.tray_status(2, err.message); //Red tray icon
return false;
}
app.debug('Result seems to be fine');
output.touch();
output.setWritable();
console.log('!!!');
var csscode = tree.toCSS();
console.log(csscode);
console.log(tree);
console.log('...');
if (minify) {
app.debug('Minifying CSS...');
csscode = CleanCSS.process(csscode);
Expand All @@ -620,6 +624,7 @@ var app = {
});
}
catch(e) {
app.debug('Got an parse error');
parse_result = false;
for (var key in e) {
app.debug(key + ' => ' + e[key]);
Expand All @@ -635,10 +640,12 @@ var app = {
import_error_func: function(e){
var err = e,
indexed_less_file_object = app.compiling_file;
indexed_less_file_object.compiler_error = err.message.replace(/(on line \d+)/, ' in '+e.filename+' <span style="font-weight: bold;">$1</span>');
indexed_less_file_object.compile_status = 2;
indexed_less_file_object.compiler_error = err.message.replace(/(on line \d+)/, ' in '+e.filename+' <span style="font-weight: bold;">$1</span>');
indexed_less_file_object.compile_status = 2;
app.tray_status(2, err.message.replace(/(on line \d+)/, ' in '+e.filename+' $1')); //Red tray icon
app.list_update();
//Don't ask me why, but when an error happens in imported files, the parser got stuck.
app.parser = new less.Parser();
},

/**
Expand Down
1 change: 1 addition & 0 deletions Resources/js/less.js
Expand Up @@ -2853,6 +2853,7 @@ function createCSS(styles, sheet, lastModified) {

function xhr(url, type, callback, errback) {
//If there is no file ending, LESS assumes you are trying to include a LESS file.
app.debug('LESS XHR: '+url);
if(url.substr(-4) != '.css' && url.substr(-5) != '.less') url += '.less';
var file = app.compiling_file.infile.parent().resolve(url);
var src = file.open().read().toString();
Expand Down
2 changes: 1 addition & 1 deletion tiapp.xml
Expand Up @@ -3,7 +3,7 @@
<!-- These values are edited/maintained by Titanium Developer -->
<id>com.wearekiss.simpless.open</id>
<name>SimpLESS</name>
<version>1.2</version>
<version>1.3</version>
<publisher>KISS</publisher>
<url>http://wearekiss.com</url>
<icon>icon.png</icon>
Expand Down

0 comments on commit 23421fe

Please sign in to comment.