How to use the @iarna/toml.parse function in @iarna/toml

To help you get started, we’ve selected a few @iarna/toml 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 clio-lang / clio / package / packageConfig.js View on Github external
function getPackageConfig(filepath = path.join(process.cwd(), configFileName)) {
  const file = fs.readFileSync(filepath);
  const packageConfig = toml.parse(file);

  return {
    title: packageConfig.title,
    description: packageConfig.description,
    version: packageConfig.version,
    license: packageConfig.license,
    main: packageConfig.main,
    authors: packageConfig.authors,
    keywords: packageConfig.keywords,
    // eslint-disable-next-line camelcase
    git_repository: packageConfig.git_repository,
    documentation: packageConfig.documentation,

    scripts: packageConfig.scripts,
    dependencies: Object.entries(packageConfig.dependencies).map(dep => {
      return { name: dep[0], version: dep[1] };
github entropic-dev / entropic / cli / lib / load-package-toml.js View on Github external
async function load(dir) {
  do {
    try {
      const src = await fs.readFile(path.join(dir, 'Package.toml'), 'utf8');
      return { location: dir, content: toml.parse(src) };
    } catch (err) {
      if (err.code !== 'ENOENT') {
        throw err;
      }
    }

    const newDir = path.resolve(dir, '..');
    if (newDir === dir) {
      throw new Error('Could not find Package.toml.');
    }

    dir = newDir;
  } while (true); // eslint-disable-line no-constant-condition
}
github Financial-Times / polyfill-library / test / polyfills / test-individual-feature.js View on Github external
const thirdPartyDependenciesForFeature = filesRequiredByFeature.filter(file => file.endsWith('/config.toml')).map(file => {
        const config = TOML.parse(fs.readFileSync(path.join(__dirname, '../../', file), 'utf-8'));
        return config.install && config.install.module;
    }).filter(thirdPartyPolyfills => thirdPartyPolyfills !== undefined);
github ChatPlug / ChatPlug / src / ChatPlugConfig.ts View on Github external
readConfigForService(service: Service) {
    return TOML.parse(fs.readFileSync(
      path.join(
        configFolderPath,
        service.moduleName + '.' + service.id + '.toml',
      ),
      'utf8',
    ) as string)
  }
github DavidWells / configorama / lib / parsers / toml.js View on Github external
function parse(contents) {
  let object
  try {
    object = TOML.parse(contents)
  } catch (e) {
    throw new Error(e)
  }
  return object
}
github Voxelum / minecraft-launcher-core-node / packages / forge / index.ts View on Github external
async function tomlMetadata(fs: FileSystem, modidTree: ModidTree, manifest: any) {
    const existed = await fs.existsFile("META-INF/mods.toml");
    if (existed) {
        const str = await fs.readFile("META-INF/mods.toml", "utf-8");
        const map = parseToml(str);
        if (map.mods instanceof Array) {
            for (const mod of map.mods) {
                const tomlMod = mod as any;
                const modObject: Partial = {
                    modid: tomlMod.modId,
                    authorList: typeof map.authors === "string" ? [map.authors] : [],
                    version: tomlMod.version === "${file.jarVersion}"
                        ? manifest?.["Implementation-Version"] : tomlMod.version,
                    name: typeof tomlMod.displayName === "string" ? tomlMod.displayName : "",
                    displayName: tomlMod.displayName,
                    description: tomlMod.description,
                    loaderVersion: map.loaderVersion as string,
                    url: typeof map.displayURL === "string" ? map.displayURL : undefined,
                }
                if (typeof modObject.modid === "string") {
                    if (modObject.modid in modidTree) {
github smartcontractkit / chainlink / operator_ui / src / pages / Jobs / utils.ts View on Github external
export function isToml({ value }: { value: string }): JobSpecFormats | false {
  try {
    if (value !== '' && TOML.parse(value)) {
      return JobSpecFormats.TOML
    } else {
      return false
    }
  } catch {
    return false
  }
}
github bcoe / toml-to-env / index.js View on Github external
process.nextTick(() => {
    try {
      const data = TOML.parse(fs.readFileSync(path, 'utf-8'))
      return cb(null, data.environment || {})
    } catch (err) {
      return cb(err)
    }
  })
}
github ArcBlock / forge-js / forge / forge-config / lib / index.js View on Github external
function parse(configPath) {
  if (!fs.existsSync(configPath)) {
    throw new Error(`config file not found: ${configPath}`);
  }
  try {
    return camelize(toml.parse(fs.readFileSync(configPath)));
  } catch (err) {
    throw new Error(`config file parse failed: ${configPath}`);
  }
}

@iarna/toml

Better TOML parsing and stringifying all in that familiar JSON interface.

ISC
Latest version published 4 years ago

Package Health Score

73 / 100
Full package analysis

Popular @iarna/toml functions