-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] Variables: Include variables defined in sub-directories (#160)
Fixes: #159
- Loading branch information
Showing
11 changed files
with
191 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
test/fixtures/libraries/lib3/my/other/ui/lib/themes/base/library.source.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@import "../../../../../../my/ui/lib/themes/base/global.less"; | ||
@import "MyControl.less"; | ||
@import "sub-directory/MyOtherControl.less"; |
1 change: 1 addition & 0 deletions
1
test/fixtures/libraries/lib3/my/other/ui/lib/themes/base/sub-directory/MyOtherControl.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@_my_other_ui_lib_MyOtherControl_color1: @color1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* eslint-env mocha */ | ||
"use strict"; | ||
|
||
const assert = require("assert"); | ||
const VariableCollector = require("../lib/plugin/variable-collector"); | ||
|
||
describe("VariableCollector", function() { | ||
it("should return relevant variables when calling 'getVariables'", function() { | ||
const env = {}; | ||
const variableCollector = new VariableCollector(env); | ||
|
||
variableCollector.mVariables = { | ||
"color1": { | ||
"value": "#ffffff", | ||
"filename": "my/ui/lib/themes/foo/global.less", | ||
"rootFilename": "my/other/ui/lib/themes/foo/library.source.less" | ||
}, | ||
"_my_other_ui_lib_MyControl_color1": { | ||
"value": "#ffffff", | ||
"filename": "my/other/ui/lib/themes/foo/MyControl.less", | ||
"rootFilename": "my/other/ui/lib/themes/foo/library.source.less" | ||
}, | ||
"_my_other_ui_lib_MyOtherControl_color1": { | ||
"value": "#ffffff", | ||
"filename": "my/other/ui/lib/themes/base/sub-directory/MyOtherControl.less", | ||
"rootFilename": "my/other/ui/lib/themes/foo/library.source.less" | ||
}, | ||
"_my_other_ui_lib_MyControl_color2": { | ||
"value": "#008000", | ||
"filename": "my/other/ui/lib/themes/foo/MyControl.less", | ||
"rootFilename": "my/other/ui/lib/themes/foo/library.source.less" | ||
} | ||
}; | ||
|
||
const aImports = [ | ||
"my/ui/lib/themes/foo/global.less", | ||
"my/other/ui/lib/themes/foo/MyControl.less", | ||
"my/other/ui/lib/themes/base/library.source.less", | ||
"my/ui/lib/themes/base/global.less", | ||
"my/other/ui/lib/themes/base/MyControl.less", | ||
"my/other/ui/lib/themes/base/sub-directory/MyOtherControl.less" | ||
]; | ||
|
||
const variables = variableCollector.getVariables(aImports); | ||
|
||
assert.deepEqual(variables, { | ||
"_my_other_ui_lib_MyControl_color1": "#ffffff", | ||
"_my_other_ui_lib_MyOtherControl_color1": "#ffffff", | ||
"_my_other_ui_lib_MyControl_color2": "#008000" | ||
}, "relevant variables should be returned"); | ||
}); | ||
it("should return relevant variables when calling 'getVariables' (win32 paths)", function() { | ||
const env = {}; | ||
const variableCollector = new VariableCollector(env); | ||
|
||
variableCollector.mVariables = { | ||
"color1": { | ||
"value": "#ffffff", | ||
"filename": "my\\ui\\lib\\themes\\foo\\global.less", | ||
"rootFilename": "my\\other\\ui\\lib\\themes\\foo\\library.source.less" | ||
}, | ||
"_my_other_ui_lib_MyControl_color1": { | ||
"value": "#ffffff", | ||
"filename": "my\\other\\ui\\lib\\themes\\foo\\MyControl.less", | ||
"rootFilename": "my\\other\\ui\\lib\\themes\\foo\\library.source.less" | ||
}, | ||
"_my_other_ui_lib_MyOtherControl_color1": { | ||
"value": "#ffffff", | ||
"filename": "my\\other\\ui\\lib\\themes\\base\\sub-directory\\MyOtherControl.less", | ||
"rootFilename": "my\\other\\ui\\lib\\themes\\foo\\library.source.less" | ||
}, | ||
"_my_other_ui_lib_MyControl_color2": { | ||
"value": "#008000", | ||
"filename": "my\\other\\ui\\lib\\themes\\foo\\MyControl.less", | ||
"rootFilename": "my\\other\\ui\\lib\\themes\\foo\\library.source.less" | ||
} | ||
}; | ||
|
||
const aImports = [ | ||
"my\\ui\\lib\\themes\\foo\\global.less", | ||
"my\\other\\ui\\lib\\themes\\foo\\MyControl.less", | ||
"my\\other\\ui\\lib\\themes\\base\\library.source.less", | ||
"my\\ui\\lib\\themes\\base\\global.less", | ||
"my\\other\\ui\\lib\\themes\\base\\MyControl.less", | ||
"my\\other\\ui\\lib\\themes\\base\\sub-directory\\MyOtherControl.less" | ||
]; | ||
|
||
const variables = variableCollector.getVariables(aImports); | ||
|
||
assert.deepEqual(variables, { | ||
"_my_other_ui_lib_MyControl_color1": "#ffffff", | ||
"_my_other_ui_lib_MyOtherControl_color1": "#ffffff", | ||
"_my_other_ui_lib_MyControl_color2": "#008000" | ||
}, "relevant variables should be returned"); | ||
}); | ||
it("should return variables when calling 'getVariables' (filename = rootFilename, no imports)", function() { | ||
const env = {}; | ||
const variableCollector = new VariableCollector(env); | ||
|
||
variableCollector.mVariables = { | ||
"color1": { | ||
"value": "#ffffff", | ||
"filename": "something", | ||
"rootFilename": "something" | ||
} | ||
}; | ||
const aImports = []; | ||
|
||
const variables = variableCollector.getVariables(aImports); | ||
|
||
assert.deepEqual(variables, { | ||
"color1": "#ffffff" | ||
}, "relevant variables should be returned"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters