Skip to content

Commit d9938c1

Browse files
committed
Fix to work when react-dsfr is linked
1 parent 1898678 commit d9938c1

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/bin/only_include_used_icons.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ import type { Icon } from "./css_to_ts";
1414
import type { Equals } from "tsafe";
1515

1616
(async () => {
17-
const dsfrProjectRoot = getProjectRoot();
18-
19-
const dsfrDistDirPath = pathJoin(dsfrProjectRoot, "dsfr");
17+
const packageName = JSON.parse(
18+
fs.readFileSync(pathJoin(getProjectRoot(), "package.json")).toString("utf8")
19+
)["name"];
2020

2121
const cwd = process.cwd();
2222

23+
const nodeModulesDirPath = pathJoin(cwd, "node_modules");
24+
25+
const dsfrDistDirPath = pathJoin(...[nodeModulesDirPath, ...packageName.split("/"), "dsfr"]);
26+
2327
const icons = await collectIcons({
2428
"dsfrDistDirPath": dsfrDistDirPath,
2529
"remixiconDirPath": (() => {
26-
const nodeModulesDirPath = pathJoin(cwd, "node_modules");
27-
2830
at_the_root: {
2931
const remixiconDirPath = pathJoin(nodeModulesDirPath, "remixicon");
3032

@@ -36,11 +38,7 @@ import type { Equals } from "tsafe";
3638
}
3739

3840
const remixiconDirPath = pathJoin(
39-
nodeModulesDirPath,
40-
JSON.parse(
41-
fs.readFileSync(pathJoin(dsfrProjectRoot, "package.json")).toString("utf8")
42-
)["name"],
43-
"remixicon"
41+
...[nodeModulesDirPath, ...packageName.split("/"), "remixicon"]
4442
);
4543

4644
assert(fs.existsSync(remixiconDirPath));

test/integration/next/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function App() {
1515
<span className="fr-icon-ancient-gate-fill" aria-hidden="true"></span>
1616
<i className="fr-icon-ancient-gate-fill" aria-hidden="true"/>
1717

18-
<button className={fr.cx("fr-btn", "ri-arrow-left-s-fill", "fr-btn--icon-left")}>
18+
<button className={fr.cx("fr-btn", "ri-amazon-fill", "fr-btn--icon-left")}>
1919
Download
2020
</button>
2121

0 commit comments

Comments
 (0)