From ea6246e16d3f217a621f3c45f6944ae471dc1bce Mon Sep 17 00:00:00 2001 From: Rob Huzzey Date: Mon, 16 Oct 2017 12:36:33 +0100 Subject: [PATCH 1/4] Allows for inclusing of LESS files from node_modules without .less extension --- lib/less-node/file-manager.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/less-node/file-manager.js b/lib/less-node/file-manager.js index afe556323..542347c98 100644 --- a/lib/less-node/file-manager.js +++ b/lib/less-node/file-manager.js @@ -82,9 +82,8 @@ FileManager.prototype.loadFile = function(filename, currentDirectory, options, e } catch (e) {} } - else { - fullFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename; - } + + fullFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename; if (self.files[fullFilename]) { fulfill({ contents: self.files[fullFilename], filename: fullFilename}); From 7be05d7a4df158c76ed6fe415100ddaf4afd1cc4 Mon Sep 17 00:00:00 2001 From: Rob Huzzey Date: Wed, 18 Oct 2017 11:37:40 +0300 Subject: [PATCH 2/4] Added test for import module fix --- package.json | 3 ++- test/import-module/one/1.less | 3 +++ test/import-module/one/two/2.less | 3 +++ test/import-module/one/two/three/3.less | 3 +++ test/import-module/package.json | 11 +++++++++++ test/less/import-module.less | 3 +++ 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/import-module/one/1.less create mode 100644 test/import-module/one/two/2.less create mode 100644 test/import-module/one/two/three/3.less create mode 100644 test/import-module/package.json create mode 100644 test/less/import-module.less diff --git a/package.json b/package.json index 7842a2723..fe705d7c8 100644 --- a/package.json +++ b/package.json @@ -61,12 +61,13 @@ "grunt-eslint": "^19.0.0", "grunt-saucelabs": "^9.0.0", "grunt-shell": "^1.3.0", + "import-module": "file:test/import-module", "jit-grunt": "^0.10.0", "less-plugin-clean-css": "^1.5.1", "performance-now": "^0.2.0", "phantomjs-prebuilt": "^2.1.7", - "promise": "^7.1.1", "phin": "^2.2.3", + "promise": "^7.1.1", "time-grunt": "^1.3.0" }, "keywords": [ diff --git a/test/import-module/one/1.less b/test/import-module/one/1.less new file mode 100644 index 000000000..7ee3e9d37 --- /dev/null +++ b/test/import-module/one/1.less @@ -0,0 +1,3 @@ +.one { + color: red; +} diff --git a/test/import-module/one/two/2.less b/test/import-module/one/two/2.less new file mode 100644 index 000000000..68036dbc5 --- /dev/null +++ b/test/import-module/one/two/2.less @@ -0,0 +1,3 @@ +.two { + color: blue; +} diff --git a/test/import-module/one/two/three/3.less b/test/import-module/one/two/three/3.less new file mode 100644 index 000000000..24cab7239 --- /dev/null +++ b/test/import-module/one/two/three/3.less @@ -0,0 +1,3 @@ +.three { + color: green; +} diff --git a/test/import-module/package.json b/test/import-module/package.json new file mode 100644 index 000000000..54adf9d4e --- /dev/null +++ b/test/import-module/package.json @@ -0,0 +1,11 @@ +{ + "name": "import-module", + "version": "1.0.0", + "description": "Less files to be included in node_modules directory for testing import from node_modules", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Rob Huzzey ", + "license": "ISC" +} diff --git a/test/less/import-module.less b/test/less/import-module.less new file mode 100644 index 000000000..68928f792 --- /dev/null +++ b/test/less/import-module.less @@ -0,0 +1,3 @@ +@import 'import-module/one/two/three/3.less'; +@import 'import-module/one/two/2.less'; +@import 'import-module/one/1.less'; From 044aa24c4f6b0eb8ccd5fa91ca1bd5059b0b8965 Mon Sep 17 00:00:00 2001 From: Rob Huzzey Date: Fri, 20 Oct 2017 10:40:59 +0300 Subject: [PATCH 3/4] Added CSS to test the LESS --- test/css/import-module.css | 9 +++++++++ test/less/import-module.less | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 test/css/import-module.css diff --git a/test/css/import-module.css b/test/css/import-module.css new file mode 100644 index 000000000..c25cc8568 --- /dev/null +++ b/test/css/import-module.css @@ -0,0 +1,9 @@ +.three { + color: green; +} +.two { + color: blue; +} +.one { + color: red; +} diff --git a/test/less/import-module.less b/test/less/import-module.less index 68928f792..37dcf6674 100644 --- a/test/less/import-module.less +++ b/test/less/import-module.less @@ -1,3 +1,3 @@ -@import 'import-module/one/two/three/3.less'; -@import 'import-module/one/two/2.less'; -@import 'import-module/one/1.less'; +@import "import-module/one/two/three/3.less"; +@import "import-module/one/two/2"; +@import "import-module/one/1.less"; From 95536723e9223708b018cc9a0767d597da3a12b9 Mon Sep 17 00:00:00 2001 From: Rob Huzzey Date: Fri, 20 Oct 2017 10:50:13 +0300 Subject: [PATCH 4/4] Exclude import-module from browsert test as node_modules will not be in browser --- Gruntfile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Gruntfile.js b/Gruntfile.js index c1980ee58..9af870a6b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -291,6 +291,7 @@ module.exports = function (grunt) { 'test/less/*.less', // Don't test NPM import, obviously '!test/less/plugin-module.less', + '!test/less/import-module.less', '!test/less/javascript.less', '!test/less/urls.less', '!test/less/empty.less'