Skip to content

Commit f4edfcd

Browse files
committed
sort files for compat with ember-component-css
1 parent ee947df commit f4edfcd

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

packages/ember-css-modules/lib/output-styles-preprocessor.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

3+
const path = require('path');
34
const debug = require('debug')('ember-css-modules:output-styles-preprocessor');
45
const Concat = require('broccoli-concat');
56
const MergeTrees = require('broccoli-merge-trees');
@@ -78,6 +79,15 @@ module.exports = class OutputStylesPreprocessor {
7879
return build.apply(this, arguments);
7980
};
8081

82+
// NOTE: we sort file paths using our unique method and then add them to the header
83+
// so they maintain order. If we don't broccoli-concat would reoder anyway
84+
let calculatePatch = concat.calculatePatch;
85+
concat.calculatePatch = function() {
86+
let patch = calculatePatch.apply(this, arguments).sort(sortPatch);
87+
this.headerFiles = this.headerFiles.concat(patch.map(entry => entry[1]));
88+
return patch;
89+
}
90+
8191
return concat;
8292
}
8393

@@ -156,3 +166,21 @@ function makeIndex(a, b) {
156166

157167
return index;
158168
}
169+
170+
function sortPatch(a, b) {
171+
const sortNumber = 0;
172+
const aLevels = path.normalize(a[1]).split(path.sep).length;
173+
const bLevels = path.normalize(b[1]).split(path.sep).length;
174+
175+
if (aLevels < bLevels) {
176+
return -1;
177+
} else if (aLevels > bLevels) {
178+
return 1;
179+
} else if (a < b) {
180+
return -1;
181+
} else if (a > b) {
182+
return 1;
183+
} else {
184+
return 0;
185+
}
186+
}

packages/ember-css-modules/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-css-modules",
3-
"version": "2.0.1",
3+
"version": "2.1.0-beta.0",
44
"description": "CSS Modules for ambitious applications",
55
"scripts": {
66
"build": "ember build --environment=production",

0 commit comments

Comments
 (0)