How to use the js-yaml.default.safeLoad function in js-yaml

To help you get started, we’ve selected a few js-yaml 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 toshi1127 / css-optimization / cli / src / bin / cli.ts View on Github external
handlers,
    imageDir,
    cssDir,
    headlessFlag,
    browserType,
    puppeteerArgs
  }
}: {
  file: PathLike;
  options: RunningOptions;
}) {
  const originalBuffer = fs.readFileSync(file);
  const originalYaml = originalBuffer.toString();
  const convertedYaml = convert(originalYaml);

  const doc = yaml.safeLoad(convertedYaml);
  if (doc.skip) {
    console.log(`${file} skip...`);
    return;
  }

  if (doc.onlyBrowser && !doc.onlyBrowser.includes(browserType)) {
    console.log(
      `this scenario only browser ${doc.onlyBrowser} ${file} skip...`
    );
    return;
  }

  if (!doc.name) {
    console.error(`scenario: ${file} must be set name prop`);
    return;
  }