Skip to content

Commit 1373275

Browse files
mightyalekseyAlexey Litvinov
authored andcommitted
presets implementation
1 parent a985863 commit 1373275

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
"glob-to-regexp": "^0.1.0",
3737
"icss-replace-symbols": "^1.0.2",
3838
"lodash": "^4.3.0",
39-
"lookup-fs": "^1.0.0",
4039
"postcss": "^5.0.15",
4140
"postcss-modules-extract-imports": "^1.0.0",
4241
"postcss-modules-local-by-default": "^1.0.1",
4342
"postcss-modules-parser": "^1.1.0",
4443
"postcss-modules-scope": "^1.0.0",
45-
"postcss-modules-values": "^1.1.1"
44+
"postcss-modules-values": "^1.1.1",
45+
"seekout": "^1.0.1"
4646
},
4747
"devDependencies": {
4848
"mocha": "^2.4.5",

preset.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
const dirname = require('path').dirname;
12
const hook = require('.');
2-
const lookup = require('lookup-fs');
3+
const seekout = require('seekout');
34

4-
// should it be a sync call?
5-
lookup('cmrh.conf.js', module.parent.filename, (er, cssModulesFilePath) => {
6-
if (er) {
7-
throw new Error('Unable to find cmrh.conf.js');
8-
}
5+
const preset = seekout('cmrh.conf.js', dirname(module.parent.filename));
6+
if (!preset) {
7+
throw new Error('Unable to find cmrh.conf.js');
8+
}
99

10-
const preset = require(cssModulesFilePath);
11-
hook(preset);
12-
});
10+
hook(require(preset));

test/preset/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ suite('css-modules-require-hook/preset', () => {
66

77
test('should return tokens', () => {
88
const tokens = require('./fixture/oceanic.css');
9-
assert.deepEqual(tokens, {});
9+
assert.deepEqual(tokens, {
10+
color: 'oceanic__color___1sqWL',
11+
});
1012
});
1113

1214
teardown(() => {

0 commit comments

Comments
 (0)