feat: add mex pattern add command - #9
Conversation
|
I made the required changes , please review my PR |
theDakshJaitly
left a comment
There was a problem hiding this comment.
Nice work overall, clean structure and good tests. A few things to address:
1. Missing patterns/ directory creation
If the patterns/ dir doesn't exist yet, writeFileSync will throw. Add a mkdirSync(patternsDir, { recursive: true }) before writing the file.
2. INDEX.md append could break formatting
appendFileSync just tacks on the entry. If INDEX.md doesn't end with a newline, the new row gets glued to the last line. Worth reading the file first and adding a newline if needed.
3. No validation on the name argument
Spaces or special characters in the name would create weird file paths. Something like mex pattern add "foo bar" would produce foo bar.md. Should probably validate that the name is a simple slug (letters, numbers, hyphens).
4. Minor: [description] placeholder in INDEX.md
The appended row has a hardcoded [description] placeholder. Not a blocker but worth noting that the user has to manually edit INDEX.md after running the command. Could mention that in the console output.
Please fix #1 and #3, the others are optional but nice to have.
theDakshJaitly
left a comment
There was a problem hiding this comment.
Looks good, all feedback addressed. Nice work!
Adds a new CLI command
mex pattern add <name>to create pattern files and update INDEX.md automatically.