Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { base, components } = state.config.source
const configPath = componentIdToFilePath(components, id)
const dir = dirname(configPath)
const readmePath = join(dir, COMPONENT_DOCSNAME)
const sourcePath = crossPlatformPath(relative(base, dir))
const data = { attributes: {}, sourcePath }
// config
if (exists(configPath)) {
data.attributes = requireUncached(configPath)
data.sourceFile = crossPlatformPath(relative(base, configPath))
}
// readme
if (exists(readmePath)) {
data.content = await MarkdownUtil.fromFile(readmePath)
data.readmeFile = crossPlatformPath(relative(base, readmePath))
}
debug4(state, `Component.readComponentFiles(${id}):end`)
return data
}
const configPath = pageIdToFilePath(pages, id)
const dir = dirname(configPath)
const readmePath = join(dir, PAGE_DOCSNAME)
const sourcePath = crossPlatformPath(relative(base, dir))
const data = { attributes: {}, sourcePath }
// config
if (exists(configPath)) {
data.attributes = requireUncached(configPath)
data.sourceFile = crossPlatformPath(relative(base, configPath))
}
// readme
if (exists(readmePath)) {
data.content = await MarkdownUtil.fromFile(readmePath)
data.readmeFile = crossPlatformPath(relative(base, readmePath))
}
debug4(state, `Page.readPageFiles(${id}):end`)
return data
}