Skip to content

Commit 7a5a398

Browse files
authored
fix: makes doc dir before writing to it and adds to .gitignore (#426)
When writing docs, if you do not already have a `/src/docs` directory, the script would fail while attempting to write to it. Now it checks for that directory and creates one if needed. The reason this could happen is because that directory is ignored from git, and so unless you've previously written to it, you will not have this directory on your machine.
1 parent be2a193 commit 7a5a398

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

3+
/src/docs
4+
35
# dependencies
46
/node_modules
57
/.pnp

scripts/fetch-docs.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ async function fetchDocs() {
185185
const data = JSON.stringify(topics.filter(Boolean), null, 2)
186186
const docsFilename = path.resolve(__dirname, outputDirectory)
187187

188+
const dir = path.dirname(docsFilename)
189+
190+
if (!fs.existsSync(dir)) {
191+
fs.mkdirSync(dir, { recursive: true })
192+
}
193+
188194
fs.writeFile(docsFilename, data, (err) => {
189195
if (err) {
190196
console.error(err)

0 commit comments

Comments
 (0)