How to use the @uiengine/util/src/parsing.fromFileSync function in @uiengine/util

To help you get started, we’ve selected a few @uiengine/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dennisreimann / uiengine / packages / cli / src / yaml.js View on Github external
})

const parseString = (string, filename, sourcePaths) => {
  try {
    const IncludeYamlType = includeYamlType(filename, sourcePaths)
    const DataYamlType = dataYamlType(filename, sourcePaths)
    const schema = yaml.Schema.create([IncludeYamlType, DataYamlType, MarkdownYamlType])
    const json = true // duplicate keys in a mapping will override values rather than throwing an error

    return yaml.safeLoad(string.trim(), { schema, filename, json })
  } catch (err) {
    throw new UiengineInputError(['Could not parse YAML!', markSample(string)], err)
  }
}

const fromFileSync = R.partial(parsing.fromFileSync, [parseString])
const fromFile = R.partial(parsing.fromFile, [parseString])
const fromString = R.partial(parsing.fromString, [parseString])

module.exports = {
  parseString,
  fromFileSync,
  fromFile,
  fromString
}