Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Make sure we clean-up on exit
function cleanupAndExit() {
return watcher.quit();
}
process.on('SIGINT', cleanupAndExit);
process.on('SIGTERM', cleanupAndExit);
// Sync build directory on build success
watcher.on('buildSuccess', () => {
syncBuildFolder(builder, outputDir);
onSuccess();
});
// Start serving!
broccoli.server.serve(
watcher,
'127.0.0.1',
port || 4300,
undefined,
undefined,
new UI(),
);
return watcher;
}
export default function docify(options = {}) {
let port = options.port || 3000;
let docsPath = options.src || 'docs';
let pkgPath = options.pkg || process.cwd();
let themePath = options.theme
|| fs.existsSync('docs/theme') && 'docs/theme'
|| path.join(__dirname, '../themes/minimal');
let builder = new broccoli.Builder(docsTree({ docsPath, pkgPath, themePath }));
let server = broccoli.server.serve(builder, { host: 'localhost', port });
// Start a livereload server
let lrserver = tinylr();
lrserver.listen(35729, () => {
setTimeout(() => {
// Trigger a reload on first start
lrserver.changed({ body: { files: [ 'livereload files' ] } });
}, 1000);
});
// Notify it on changes
server.watcher.on('change', function() {
lrserver.changed({ body: { files: [ 'livereload files' ] } });
});
}