forgecss 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +2 -2
- package/index.d.ts +3 -3
- package/index.js +11 -7
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -55,9 +55,9 @@ async function runForgeCSS(lookAtPath = null) {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
if (lookAtPath) {
|
|
58
|
-
instance.parseFile(lookAtPath, config.output);
|
|
58
|
+
instance.parseFile({ file: lookAtPath, output: config.output });
|
|
59
59
|
} else {
|
|
60
|
-
instance.parseDirectory(config.dir, config.output);
|
|
60
|
+
instance.parseDirectory({ dir: config.dir, output: config.output });
|
|
61
61
|
}
|
|
62
62
|
if (options.verbose) {
|
|
63
63
|
console.log(`forgecss: ${config.output} generated successfully.`);
|
package/index.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ export type ForgeCSSOptions = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export type ForgeInstance = {
|
|
13
|
-
parseDirectory: (
|
|
14
|
-
parseFile: (
|
|
15
|
-
parse: (css: string
|
|
13
|
+
parseDirectory: (options: { dir: string; output?: string }) => Promise<string>;
|
|
14
|
+
parseFile: (options: { file: string; output?: string }) => Promise<string>;
|
|
15
|
+
parse: (options: { css: string; html?: string; jsx?: string; output?: string }) => Promise<string>;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
declare function ForgeCSS(options?: ForgeCSSOptions): ForgeInstance;
|
package/index.js
CHANGED
|
@@ -34,7 +34,7 @@ export default function ForgeCSS(options) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
return {
|
|
37
|
-
async parseDirectory(dir, output = null) {
|
|
37
|
+
async parseDirectory({ dir, output = null }) {
|
|
38
38
|
if (!dir) {
|
|
39
39
|
throw new Error('forgecss: parseDirectory requires "dir" as an argument.');
|
|
40
40
|
}
|
|
@@ -59,7 +59,7 @@ export default function ForgeCSS(options) {
|
|
|
59
59
|
// generating the output CSS
|
|
60
60
|
return result(output);
|
|
61
61
|
},
|
|
62
|
-
async parseFile(file, output = null) {
|
|
62
|
+
async parseFile({ file, output = null }) {
|
|
63
63
|
if (!file) {
|
|
64
64
|
throw new Error('forgecss: parseFile requires "file" as an argument.');
|
|
65
65
|
}
|
|
@@ -84,12 +84,12 @@ export default function ForgeCSS(options) {
|
|
|
84
84
|
// generating the output CSS
|
|
85
85
|
return result(output);
|
|
86
86
|
},
|
|
87
|
-
async parse(css, html, output = null) {
|
|
87
|
+
async parse({ css, html, jsx, output = null }) {
|
|
88
88
|
if (!css) {
|
|
89
|
-
throw new Error('forgecss: parse requires "css"
|
|
89
|
+
throw new Error('forgecss: parse requires "css".');
|
|
90
90
|
}
|
|
91
|
-
if (!html) {
|
|
92
|
-
throw new Error('forgecss: parse requires "html"
|
|
91
|
+
if (!html && !jsx) {
|
|
92
|
+
throw new Error('forgecss: parse requires "html" or "jsx".');
|
|
93
93
|
}
|
|
94
94
|
invalidateInvetory();
|
|
95
95
|
invalidateUsageCache();
|
|
@@ -101,7 +101,11 @@ export default function ForgeCSS(options) {
|
|
|
101
101
|
}
|
|
102
102
|
// finding the usages
|
|
103
103
|
try {
|
|
104
|
-
|
|
104
|
+
if (html) {
|
|
105
|
+
await findUsages("usage.html", html);
|
|
106
|
+
} else if (jsx) {
|
|
107
|
+
await findUsages("usage.jsx", jsx);
|
|
108
|
+
}
|
|
105
109
|
} catch (err) {
|
|
106
110
|
console.error(`forgecss: error extracting usages.`, err);
|
|
107
111
|
}
|