Skip to content

Commit c816718

Browse files
authored
Merge pull request #76 from gisce/data-root-option
Allow to pass data-root to command line
2 parents 7b7efff + 8c6828c commit c816718

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

bin/generate.js

100755100644
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ program
1111
.option('-l, --logo <location>', 'Project logo location (48x48px PNG).')
1212
.option('-f, --favicon <location>', 'Project favicon location (ICO).')
1313
.option('-o, --output <location>', 'Where to save the file (defaults to current working directory).')
14+
.option('-d, --data-root <docs-root>', 'Docs root for the API documentation.', '')
1415
.parse(process.argv);
1516

16-
const { config, logo, favicon, output } = program;
17+
18+
const { config, logo, favicon, output, dataRoot } = program;
1719

1820
if (!config) {
1921
console.log('You must provide an exported Insomnia config (Preferences -> Data -> Export Data -> Current Workspace).');
@@ -49,9 +51,18 @@ mkdirp(outputPath, err => {
4951
fs.copyFileSync(logoPath, path.join(outputPath, 'logo.png'));
5052
}
5153

54+
try {
55+
const data = fs.readFileSync(path.join(outputPath, 'index.html'), 'utf8')
56+
var result = data.replace('<div id="app">', `<div id="app" data-root="${dataRoot}">`);
57+
fs.writeFileSync(path.join(outputPath, 'index.html'), result)
58+
} catch (err) {
59+
console.error(err)
60+
}
61+
5262
if (faviconPath) {
5363
console.log('Adding custom favicon...');
5464
fs.copyFileSync(faviconPath, path.join(outputPath, 'favicon.ico'));
65+
5566
}
5667

5768
console.log('\n * * * Done! * * *\nYour documentation has been created and it\'s ready to be deployed!');

0 commit comments

Comments
 (0)