Skip to content

Commit 26e3bdf

Browse files
committed
Rename update_dsfr_static_resources to copy_dsfr_dist_to_public
1 parent 5520eb9 commit 26e3bdf

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env node
2+
3+
import { join as pathJoin } from "path";
4+
import * as fs from "fs";
5+
import { getProjectRoot } from "./tools/getProjectRoot";
6+
7+
const projectDirPath = process.cwd();
8+
9+
const publicDirPath = pathJoin(projectDirPath, "public");
10+
11+
if (!fs.existsSync(publicDirPath)) {
12+
const reactDsfrRepoUrl = JSON.parse(
13+
fs.readFileSync(pathJoin(getProjectRoot(), "package.json")).toString("utf8")
14+
)
15+
["repository"]["url"].replace(/^git/, "https:")
16+
.replace(/\.git$/, "");
17+
18+
console.error(
19+
[
20+
"There is no public/ directory in the current working directory, we don't know your framework",
21+
"you are not calling this script at the right location or we don't know your React framework",
22+
`please submit an issue about it here ${reactDsfrRepoUrl}/issues`
23+
].join(" ")
24+
);
25+
26+
process.exit(-1);
27+
}
28+
29+
const dsfrDirPath = pathJoin(publicDirPath, "dsfr");
30+
31+
if (fs.existsSync(dsfrDirPath)) {
32+
fs.rmSync(dsfrDirPath, { "recursive": true, "force": true });
33+
}
34+
35+
fs.cpSync(pathJoin(projectDirPath, "node_modules", "@gouvfr", "dsfr", "dist"), dsfrDirPath, {
36+
"recursive": true
37+
});

0 commit comments

Comments
 (0)