Skip to content

Commit

Permalink
fix: detect absolute paths for output file and treat them as such (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
lirantal authored Aug 6, 2022
1 parent eaaf016 commit d20a2e9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bin/output-handler.js
Original file line number Diff line number Diff line change
@@ -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)
}
Expand Down

0 comments on commit d20a2e9

Please sign in to comment.