Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const processArgs = this.options.argv.slice(2)
const { args } = this.options
const { verbose, version, files, watch, 'template-require': templateRequireLib, preview } = args
if (version || (verbose && processArgs.length === 1)) {
process.stdout.write(`Asciidoctor PDF ${pkg.version} using `)
Invoker.printVersion()
return { exit: true }
}
let templates
if (templateRequireLib) {
templates = Invoker.requireLibrary(templateRequireLib)
} else {
templates = require('./document/templates.js')
}
converter.registerTemplateConverter(processor, templates)
Invoker.prepareProcessor(args, processor)
const options = this.options.options
if (files && files.length > 0) {
await convertFiles(files, args, options, verbose, preview)
if (watch) {
const watchFiles = files.map((file) => {
const dirname = path.dirname(file)
const allSubdirPath = path.join(dirname, '**')
return [
path.join(allSubdirPath, '*.css'),
path.join(allSubdirPath, '*.js'),
path.join(allSubdirPath, '*.adoc'),
file
]
})
console.log('Watch mode entered, needs to be manually terminated using Ctrl+C!')
chokidar.watch(watchFiles, { ignored: /(^|[/\\])\../ }).on('change', async (path) => {