Skip to content

Commit

Permalink
sync: make parameter order more consistent
Browse files Browse the repository at this point in the history
Still not great.
  • Loading branch information
ee7 committed Jun 24, 2021
1 parent d807ae3 commit 136fbc9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
13 changes: 6 additions & 7 deletions src/sync/sync.nim
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ proc sync*(conf: Conf) =
case syncKind
# Check/sync docs
of skDocs:
let sdPairs = checkDocs(exercises, psExercisesDir,
trackPracticeExercisesDir, seenUnsynced, conf)
let sdPairs = checkDocs(conf, seenUnsynced, trackPracticeExercisesDir,
exercises, psExercisesDir)
if sdPairs.len > 0: # Implies that `--update` was passed.
if conf.action.yes or userSaysYes(syncKind):
for sdPair in sdPairs:
Expand All @@ -56,15 +56,14 @@ proc sync*(conf: Conf) =

# Check/sync filepaths
of skFilepaths:
let configPairs = checkFilepaths(conf, trackConceptExercisesDir,
trackPracticeExercisesDir, seenUnsynced)
let configPairs = checkFilepaths(conf, seenUnsynced, trackPracticeExercisesDir,
trackConceptExercisesDir)
update(configPairs, conf, syncKind, seenUnsynced)

# Check/sync metadata
of skMetadata:
let configPairs = checkMetadata(exercises, psExercisesDir,
trackPracticeExercisesDir, seenUnsynced,
conf)
let configPairs = checkMetadata(conf, seenUnsynced, trackPracticeExercisesDir,
exercises, psExercisesDir)
update(configPairs, conf, syncKind, seenUnsynced)

# Check/sync tests
Expand Down
8 changes: 4 additions & 4 deletions src/sync/sync_docs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ proc checkFilesIdentical(source, dest, slug, filename: string;
if conf.action.update:
sdPairs.add SourceDestPair(source: source, dest: dest)

proc checkDocs*(exercises: seq[Exercise],
psExercisesDir: string,
trackPracticeExercisesDir: string,
proc checkDocs*(conf: Conf,
seenUnsynced: var set[SyncKind],
conf: Conf): seq[SourceDestPair] =
trackPracticeExercisesDir: string,
exercises: seq[Exercise],
psExercisesDir: string): seq[SourceDestPair] =
for exercise in exercises:
let slug = exercise.slug.string
let trackDocsDir = joinPath(trackPracticeExercisesDir, slug, ".docs")
Expand Down
6 changes: 3 additions & 3 deletions src/sync/sync_filepaths.nim
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ proc checkFilepathsForExercise(res: var seq[PathAndUpdatedJson], conf: Conf,
res.add PathAndUpdatedJson(path: trackExerciseConfigPath,
updatedJson: j)

proc checkFilepaths*(conf: Conf;
trackConceptExercisesDir, trackPracticeExercisesDir: string;
seenUnsynced: var set[SyncKind]): seq[PathAndUpdatedJson] =
proc checkFilepaths*(conf: Conf; seenUnsynced: var set[SyncKind],
trackPracticeExercisesDir: string,
trackConceptExercisesDir: string): seq[PathAndUpdatedJson] =
let configFilename = "config.json"
let trackConfigPath = conf.trackDir / configFilename

Expand Down
8 changes: 4 additions & 4 deletions src/sync/sync_metadata.nim
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ proc isThisMetadataSynced(res: var seq[PathAndUpdatedJson]; conf: Conf; slug: st
else:
logNormal(&"[error] {slug}: {psMetadataTomlPath} is missing")

proc checkMetadata*(exercises: seq[Exercise],
psExercisesDir: string,
trackPracticeExercisesDir: string,
proc checkMetadata*(conf: Conf,
seenUnsynced: var set[SyncKind],
conf: Conf): seq[PathAndUpdatedJson] =
trackPracticeExercisesDir: string,
exercises: seq[Exercise],
psExercisesDir: string): seq[PathAndUpdatedJson] =
for exercise in exercises:
let slug = exercise.slug.string
let trackMetaDir = joinPath(trackPracticeExercisesDir, slug, ".meta")
Expand Down

0 comments on commit 136fbc9

Please sign in to comment.