()
| 37 | const fileExists = (s) => fs.access(s, constants.F_OK).then(() => true).catch(() => false) |
| 38 | |
| 39 | async 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 | |
| 64 | async function updateContents(file, docsPath) { |
| 65 | const content = await fs.readFile(file, 'utf-8') |
no test coverage detected