MCPcopy Create free account
hub / github.com/exercism/cli / documents

Method documents

cmd/submit.go:218–244  ·  view source on GitHub ↗

documents builds the documents that get submitted. Empty files are skipped, printing a warning.

(submitPaths []string, exercise workspace.Exercise)

Source from the content-addressed store, hash-verified

216// documents builds the documents that get submitted.
217// Empty files are skipped, printing a warning.
218func (s *submitCmdContext) documents(submitPaths []string, exercise workspace.Exercise) ([]workspace.Document, error) {
219 docs := make([]workspace.Document, 0, len(submitPaths))
220 for _, file := range submitPaths {
221 // Don't submit empty files
222 info, err := os.Stat(file)
223 if err != nil {
224 return nil, err
225 }
226 if info.Size() == 0 {
227
228 msg := `
229
230 WARNING: Skipping empty file
231 %s
232
233 `
234 fmt.Fprintf(Err, msg, file)
235 continue
236 }
237 doc, err := workspace.NewDocument(exercise.Filepath(), file)
238 if err != nil {
239 return nil, err
240 }
241 docs = append(docs, doc)
242 }
243 return docs, nil
244}
245
246func (s *submitCmdContext) metadata(exercise workspace.Exercise) (*workspace.ExerciseMetadata, error) {
247 metadata, err := workspace.NewExerciseMetadata(exercise.Filepath())

Callers 1

runSubmitFunction · 0.80

Calls 2

NewDocumentFunction · 0.92
FilepathMethod · 0.45

Tested by

no test coverage detected