Skip to content

YamlParser

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/apps/config-docs-parser/src/parsers/yaml.parser.ts

Implements: IParser

Methods

MethodSignatureReturns
initializeinitialize(config: ParserConfig)Promise<void>
canParsecanParse(filePath: string)boolean
parseFileparseFile(filePath: string, content: string)Promise<ParseResult>
parseFilesparseFiles(files: ParseFileInput[])Promise<ParseResult[]>
destroydestroy()Promise<void>

Properties

PropertyType
nameany
versionany
supportedPatternsany

Where it refuses work

  • YamlParser stops the work with Error when !content — “Content is required for parsing”.
  • YamlParser stops the work with an early return when fileName.includes('docker-compose') || fileName.includes('compose.y').
  • YamlParser stops the work with an early return when firstDoc.services || firstDoc.version.
  • YamlParser stops the work with an early return when fileName.includes('.github/workflows/') || fileName.includes('/.github/workflows/').
  • YamlParser stops the work with an early return when firstDoc.on && firstDoc.jobs.
  • YamlParser stops the work with an early return when fileName.includes('.gitlab-ci').

When something fails

  • YamlParser handles failure in 1 place: it turns it into a return value in all 1.

Was this page helpful?

Download as PDF