Skip to content

Commit

Permalink
[TASK] add build docs scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
dmh committed Jun 23, 2023
1 parent a7737b9 commit 2b2a186
Show file tree
Hide file tree
Showing 6 changed files with 472 additions and 5 deletions.
22 changes: 22 additions & 0 deletions build/clean.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { deleteAsync } from 'del'
import path from 'node:path'

/**
* #### Clean the docs folder
* @async
* @returns undefined
*/
async function cleanDocs () {
try {
const cwd = process.cwd()
const dirName = path.parse(cwd).name
if (dirName === 'hubspot-fields-js') {
await deleteAsync([`${cwd}/docs/**/*`])
console.log('Clean docs folder')
}
} catch (error) {
console.error(error)
}
}

export { cleanDocs }
2 changes: 2 additions & 0 deletions build/docs.exec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { docs } from './docs.mjs'
docs()
9 changes: 9 additions & 0 deletions build/docs.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { cleanDocs } from './clean.mjs'
import { jsdocBuild } from './jsdoc.mjs'

async function docs () {
await cleanDocs()
await jsdocBuild()
}

export { docs }
21 changes: 21 additions & 0 deletions build/jsdoc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { execa } from 'execa'

/**
* #### run jsdoc build
* @async
* @returns undefined
*/
async function jsdocBuild () {
try {
const jsdocConfig = [
'-c',
'jsdoc.json'
]
const { stdout } = await execa('npm', ['exec', '--', 'jsdoc', ...jsdocConfig])
console.log(stdout)
} catch (error) {
console.error(error)
}
}

export { jsdocBuild }
Loading

0 comments on commit 2b2a186

Please sign in to comment.