1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.default = wrapInClass;
|
5 | exports.hoistImports = hoistImports;
|
6 |
|
7 | var _commonTags = require("common-tags");
|
8 |
|
9 | function hoistImports(text) {
|
10 | const imports = [];
|
11 | let match;
|
12 | const rImports = /@(?:import|use|forward).*?(?:$|;)/g;
|
13 |
|
14 | while (match = rImports.exec(text)) {
|
15 | imports.push(match[0]);
|
16 | }
|
17 |
|
18 | text = text.replace(rImports, '').trim();
|
19 | return [text, imports];
|
20 | }
|
21 |
|
22 | function wrapInClass(text) {
|
23 | const [ruleset, imports] = hoistImports(text);
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | let val = (0, _commonTags.stripIndents)`
|
31 | .cls1 { /*!*/ }
|
32 | .cls2 {
|
33 | composes: cls1;
|
34 |
|
35 | ${ruleset}
|
36 | }`;
|
37 | if (imports.length) val = `${imports.join('\n')}\n${val}`;
|
38 | return val;
|
39 | } |
\ | No newline at end of file |