Skip to content

Commit 8f8f76c

Browse files
ErikSchierboomee7
andauthored
sync(filepaths): sync editor field when missing (#576)
This fixes a bug that stopped `configlet sync -u` from writing `editor` filepaths. So far, only the reasonml track has an `files.editor` key in the track `config.json`, so this bug hasn't had much impact. Before this PR: $ git clone https://github.com/exercism/reasonml.git $ cd reasonml $ git checkout 02b6e04f95b00debeab849fee4b11f45c4274733 $ jq '.files.editor' config.json [ "src/%{pascal_slug}.rei" ] $ jq '.files' exercises/practice/acronym/.meta/config.json { "solution": [ "src/Acronym.re" ], "test": [ "__tests__/Acronym_test.re" ], "example": [ ".meta/src/Example.re" ] } $ configlet sync --filepaths -e acronym -uy Checking exercises... [warn] filepaths: unsynced: acronym Updated the filepaths for 1 exercise The `acronym` exercise has up-to-date filepaths! $ git status HEAD detached at 02b6e04 nothing to commit, working tree clean With this PR, after the same `configlet sync` command: $ git diff --- a/exercises/practice/acronym/.meta/config.json +++ b/exercises/practice/acronym/.meta/config.json @@ -19,6 +19,9 @@ ], "example": [ ".meta/src/Example.re" + ], + "editor": [ + "src/Acronym.rei" ] }, "source": "Julien Vanier", Co-authored-by: ee7 <45465154+ee7@users.noreply.github.com>
1 parent 6b61086 commit 8f8f76c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/sync/sync_common.nim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,11 @@ func filesKeyOrder(val: ConceptExerciseFiles | PracticeExerciseFiles;
361361
let insertionIndex = result.find(fkTest) + 1
362362
result.insert(fkEx, insertionIndex)
363363

364+
# If `editor` is missing and not empty, write it after `example`/`exemplar`.
365+
if fkEditor notin result and val.editor.len > 0:
366+
let insertionIndex = result.find(fkEx) + 1
367+
result.insert(fkEditor, insertionIndex)
368+
364369
func addFiles(s: var string; val: ConceptExerciseFiles | PracticeExerciseFiles;
365370
prettyMode: PrettyMode; indentLevel = 1) =
366371
## Appends the pretty-printed JSON for a `files` key with value `val` to `s`.

0 commit comments

Comments
 (0)