How to use read-yaml-file - 4 common examples

To help you get started, we’ve selected a few read-yaml-file 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 pnpm / pnpm / privatePackages / assert-project / src / index.ts View on Github external
async readLockfile () {
      try {
        return await readYamlFile(path.join(projectPath, WANTED_LOCKFILE)) // tslint:disable-line
      } catch (err) {
        if (err.code === 'ENOENT') return null!
        throw err
      }
    },
    async writePackageJson (pkgJson: object) {
github pnpm / pnpm / packages / find-workspace-packages / src / index.ts View on Github external
async function requirePackagesManifest (dir: string): Promise<{packages?: string[]} | null> {
  try {
    return await readYamlFile<{ packages?: string[] }>(path.join(dir, WORKSPACE_MANIFEST_FILENAME))
  } catch (err) {
    if (err['code'] === 'ENOENT') { // tslint:disable-line
      return null
    }
    throw err
  }
}
github pnpm / pnpm / packages / lockfile-file / src / read.ts View on Github external
async function _read (
  lockfilePath: string,
  prefix: string,
  opts: {
    wantedVersion?: number,
    ignoreIncompatible: boolean,
  },
): Promise {
  let lockfile
  try {
    lockfile = await readYamlFile(lockfilePath)
  } catch (err) {
    if ((err as NodeJS.ErrnoException).code !== 'ENOENT') {
      throw err
    }
    return null
  }
  // tslint:disable:no-string-literal
  if (typeof lockfile?.['specifiers'] !== 'undefined') {
    lockfile.importers = {
      '.': {
        specifiers: lockfile['specifiers'],
      },
    }
    delete lockfile['specifiers']
    for (const depType of DEPENDENCIES_FIELDS) {
      if (lockfile[depType]) {
github pnpm / pnpm / packages / read-importer-manifest / src / index.ts View on Github external
async function readPackageYaml (filePath: string) {
  try {
    return await readYamlFile(filePath)
  } catch (err) {
    if (err.name !== 'YAMLException') throw err
    err.message += `\nin ${filePath}`
    err['code'] = 'ERR_PNPM_YAML_PARSE'
    throw err
  }
}

read-yaml-file

Read and parse a YAML file

MIT
Latest version published 4 years ago

Package Health Score

76 / 100
Full package analysis

Popular read-yaml-file functions