diff --git a/bin/output-handler.js b/bin/output-handler.js index 56c2ab5..dd409a8 100644 --- a/bin/output-handler.js +++ b/bin/output-handler.js @@ -1,12 +1,20 @@ +import DebugLogger from 'debug' import { promises as fs } from 'fs' - import path from 'path' -const __dirname = process.cwd() +const debug = DebugLogger('gigsboat:app') export async function processOutput({ document, outputFile }) { if (outputFile) { - await fs.writeFile(path.join(__dirname, outputFile), document) + + if (path.isAbsolute(outputFile)) { + debug('detected absolute path for output file') + } else { + const __dirname = process.cwd() + outputFile = path.join(__dirname, outputFile) + } + + await fs.writeFile(outputFile, document) } else { console.log(document) }