Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 741d5a5

Browse files
added filename argument to the [pre]processCss functions
1 parent 4a19bef commit 741d5a5

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

‎src/index.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function fetch(_to, _from, _trace) {
9797
}
9898

9999
const rootRelativePath = sep + relative(rootDir, filename);
100-
const CSSSource = preProcess(readFileSync(filename, 'utf8'));
100+
const CSSSource = preProcess(readFileSync(filename, 'utf8'),filename);
101101

102102
const lazyResult = postcss(plugins.concat(new Parser({ fetch, filename, trace })))
103103
.process(CSSSource, assign(lazyResultOpts, {from: rootRelativePath}));
@@ -109,7 +109,7 @@ function fetch(_to, _from, _trace) {
109109
tokensByFile[filename] = tokens;
110110

111111
if (postProcess) {
112-
postProcess(lazyResult.css);
112+
postProcess(lazyResult.css,filename);
113113
}
114114

115115
return tokens;

‎test/public-api.js‎

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,32 @@ describe('public api', () => {
88
delete require.cache[require.resolve('awesome-theme/oceanic.css')];
99
});
1010

11-
describe('preprocessCss', () => {
11+
describe('preprocessCss()', () => {
12+
describe('content of the file and filename are provided to the preprocessCss function', () => {
13+
let providedCSS;
14+
let providedFilename;
15+
16+
beforeEach(() => {
17+
const spy = (content, filename) => {
18+
providedCSS = content;
19+
providedFilename = filename;
20+
return content;
21+
};
22+
23+
hook({preprocessCss: spy});
24+
require('awesome-theme/oceanic.css');
25+
});
26+
27+
it('content of file should be provided', () => {
28+
equal(typeof providedCSS, 'string');
29+
ok(providedCSS.length);
30+
});
31+
32+
it('filename should be provided', () => {
33+
equal(providedFilename, require.resolve('awesome-theme/oceanic.css'));
34+
});
35+
});
36+
1237
describe('providing empty string constantly', () => {
1338
before(() => hook({preprocessCss: constant('')}));
1439

@@ -27,4 +52,29 @@ describe('public api', () => {
2752
});
2853
});
2954
});
55+
56+
describe('processCss()', () => {
57+
let providedCSS;
58+
let providedFilename;
59+
60+
beforeEach(() => {
61+
const spy = (content, filename) => {
62+
providedCSS = content;
63+
providedFilename = filename;
64+
return content;
65+
};
66+
67+
hook({processCss: spy});
68+
require('awesome-theme/oceanic.css');
69+
});
70+
71+
it('content of file should be provided', () => {
72+
equal(typeof providedCSS, 'string');
73+
ok(providedCSS.length);
74+
});
75+
76+
it('filename should be provided', () => {
77+
equal(providedFilename, require.resolve('awesome-theme/oceanic.css'));
78+
});
79+
});
3080
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /