-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
090cdcc
commit b3ece53
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Find the docs JSON file | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const execSync = require('child_process').execSync; | ||
const rootDir = path.join(__dirname, '..'); | ||
|
||
function copyJsonSchema() { | ||
// copy the JSON schema file to the root of the project | ||
const docsDir = path.join(__dirname, '../.docusaurus/docusaurus-plugin-content-docs/default/p'); | ||
|
||
const docsFile = fs.readdirSync(docsDir).find(file => file.startsWith('docs') && file.endsWith('.json')); | ||
|
||
if (!docsFile) { | ||
throw new Error('Could not find the docs JSON file'); | ||
} | ||
|
||
// copy the docs file to the root of the project | ||
// rename the file to docs-schema.json | ||
fs.copyFileSync(path.join(docsDir, docsFile), path.join(__dirname, '../docs-schema.json')); | ||
} | ||
|
||
// execute the docusaurus build: | ||
execSync(`docusaurus build`, { cwd: rootDir, stdio: 'inherit' }); | ||
|
||
try { | ||
copyJsonSchema(); | ||
console.log('\nSuccessfully copied the docs JSON schema file to project root!\n'); | ||
} catch (e) { | ||
console.error(e); | ||
} |