Skip to content

Commit 52e39c2

Browse files
committed
fix: update README links to use correct paths and enhance update script
1 parent 78d1666 commit 52e39c2

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export default tseslint.config({
165165

166166
Contributions are welcome!
167167

168-
Please follow our [contributing guidelines](https://github.com/Rel1cx/eslint-react/tree/main/.github/CONTRIBUTING.md).
168+
Please follow our [contributing guidelines](.github/CONTRIBUTING.md).
169169

170170
## License
171171

packages/plugins/eslint-plugin/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ export default tseslint.config({
165165

166166
Contributions are welcome!
167167

168-
Please follow our [contributing guidelines](https://github.com/Rel1cx/eslint-react/tree/main/.github/CONTRIBUTING.md).
168+
Please follow our [contributing guidelines](https://github.com/Rel1cx/eslint-react/tree/2.0.0/.github/CONTRIBUTING.md).
169169

170170
## License
171171

172-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
172+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/Rel1cx/eslint-react/tree/2.0.0/LICENSE) file for details.

scripts/update-readme.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
import * as NodeContext from "@effect/platform-node/NodeContext";
22
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
3+
import * as Command from "@effect/platform/Command";
4+
import * as CommandExecutor from "@effect/platform/CommandExecutor";
35
import * as FileSystem from "@effect/platform/FileSystem";
46
import * as Effect from "effect/Effect";
57

8+
const getCurrentBranch = Command.make("git", "branch", "--show-current");
9+
610
const program = Effect.gen(function*() {
711
const fs = yield* FileSystem.FileSystem;
12+
const ce = yield* CommandExecutor.CommandExecutor;
13+
const branch = yield* ce.string(getCurrentBranch);
814
const source = "README.md";
915
const destination = "packages/plugins/eslint-plugin/README.md";
10-
1116
// Ensure the destination directory exists
1217
yield* fs.makeDirectory("packages/plugins/eslint-plugin", { recursive: true });
1318

14-
// Copy the README file
15-
yield* fs.copyFile(source, destination);
19+
const readmeContent = yield* fs.readFileString(source, "utf8");
20+
21+
// Convert relative links to absolute links
22+
const updatedContent = readmeContent.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (match, text, url) => {
23+
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("#")) {
24+
return match; // Leave absolute links unchanged
25+
}
26+
const absoluteUrl = `${`https://github.com/Rel1cx/eslint-react/tree/${branch.trim()}`}/${url.replace(/^\.\//, "")}`;
27+
return `[${text}](${absoluteUrl})`;
28+
});
1629

17-
yield* Effect.log(`Copied ${source} to ${destination}`);
30+
yield* fs.writeFileString(destination, updatedContent);
31+
yield* Effect.log(`Updated ${destination} from ${source}`);
1832
});
1933

2034
program.pipe(Effect.provide(NodeContext.layer), NodeRuntime.runMain);

0 commit comments

Comments
 (0)