From 25576eb5c61d807c073758a80d4e67a57dff0977 Mon Sep 17 00:00:00 2001 From: Nathan Hill Date: Wed, 11 Jan 2017 23:07:18 -0500 Subject: [PATCH 1/2] Bumped the version number so that a new version of the package can be deployed to npm to include the changes from commit 6d530978bf3732c9d3e16d90040e5332c5836f3d. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f15121..0855353 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-dev-less", - "version": "0.0.9", + "version": "0.0.10", "description": "LESS CSS pre-processor for NativeScript projects.", "scripts": { "test": "exit 0", From 4e8605056786699649febecff4ce186741e5c877 Mon Sep 17 00:00:00 2001 From: Nathan Hill Date: Wed, 11 Jan 2017 23:57:19 -0500 Subject: [PATCH 2/2] Made it so that the empty, unneeded css files aren't created. --- lib/converter.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/converter.js b/lib/converter.js index 1ebe7aa..adb4733 100644 --- a/lib/converter.js +++ b/lib/converter.js @@ -8,22 +8,22 @@ var glob = require('glob'); function convert(logger, projectDir, options) { return new Promise(function (resolve, reject) { options = options || {}; - + var lessFilesPath = path.join(projectDir, 'app/**/*.less'); var lessFiles = glob.sync(lessFilesPath).filter(function(fileName){ return fileName.indexOf("App_Resources") === -1; - }); - + }); + var i = 0; var loopLessFilesAsync = function(lessFiles){ parseLess(lessFiles[i], function(e){ if(e !== undefined){ //Error in the LESS parser; Reject promise - reject(Error(lessFiles[i] + ' LESS CSS pre-processing failed. Error: ' + e)); + reject(Error(lessFiles[i] + ' LESS CSS pre-processing failed. Error: ' + e)); } - + i++; //Increment loop counter - + if(i < lessFiles.length){ loopLessFilesAsync(lessFiles); } else { @@ -32,7 +32,7 @@ function convert(logger, projectDir, options) { } }); } - + loopLessFilesAsync(lessFiles); }); } @@ -47,13 +47,20 @@ function parseLess(filePath, callback){ if(e) { //Callback with error callback(e); - } - + return; + } + + if(!output.css) { + // No CSS to write to file, so just call callback without creating the file. + callback(); + return; + } + var cssFilePath = filePath.replace('.less', '.css'); fs.writeFile(cssFilePath, output.css, 'utf8', function(){ //File done writing callback(); - }); + }); }); }