Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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] };
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
}
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);
readConfigForService(service: Service) {
return TOML.parse(fs.readFileSync(
path.join(
configFolderPath,
service.moduleName + '.' + service.id + '.toml',
),
'utf8',
) as string)
}
function parse(contents) {
let object
try {
object = TOML.parse(contents)
} catch (e) {
throw new Error(e)
}
return object
}
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) {
export function isToml({ value }: { value: string }): JobSpecFormats | false {
try {
if (value !== '' && TOML.parse(value)) {
return JobSpecFormats.TOML
} else {
return false
}
} catch {
return false
}
}
process.nextTick(() => {
try {
const data = TOML.parse(fs.readFileSync(path, 'utf-8'))
return cb(null, data.environment || {})
} catch (err) {
return cb(err)
}
})
}
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}`);
}
}