MCPcopy Create free account
hub / github.com/DavidWells/analytics / getFiles

Function getFiles

site/sync.js:39–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37const fileExists = (s) => fs.access(s, constants.F_OK).then(() => true).catch(() => false)
38
39async function getFiles() {
40 const topLevelPackages = [`${PACKAGE_PATH}/*/package.json`]
41 const files = await globby(topLevelPackages)
42 const collectInfo = files.map(async (file) => {
43 const pkg = require(file)
44 const slug = pkg.name.replace(/^@analytics\//, '')
45 const directory = path.dirname(file)
46 const docFilePath = path.join(PLUGIN_DOC_PATH, `${slug}.md`)
47 const exists = await fileExists(docFilePath)
48 return {
49 pkg: pkg,
50 dir: directory,
51 exists: exists,
52 repoMdPath: path.resolve(directory, 'README.md'),
53 docPath: CUSTOM_MAPPING[pkg.name] || docFilePath
54 }
55 })
56
57 const fileData = await Promise.all(collectInfo)
58
59 return fileData.filter((info) => {
60 return CUSTOM_MAPPING[info.pkg.name] || info.exists
61 })
62}
63
64async function updateContents(file, docsPath) {
65 const content = await fs.readFile(file, 'utf-8')

Callers 1

syncDocsFunction · 0.85

Calls 1

fileExistsFunction · 0.70

Tested by

no test coverage detected