From 06079e840128030eacfecde66da11295eb162234 Mon Sep 17 00:00:00 2001 From: Juanjo Diaz Date: Thu, 24 Sep 2020 23:21:16 +0300 Subject: [PATCH] fix(cli): fix relative paths issue in CLI when not streaming (#488) --- bin/json2csv.js | 6 ++---- test/CLI.js | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/bin/json2csv.js b/bin/json2csv.js index 1cb9debc..c41aa37f 100755 --- a/bin/json2csv.js +++ b/bin/json2csv.js @@ -14,8 +14,6 @@ const TablePrinter = require('./utils/TablePrinter'); const readFile = promisify(readFileOrig); const writeFile = promisify(writeFileOrig); -const isAbsolutePath = promisify(isAbsolute); -const joinPath = promisify(join); const { unwind, flatten } = json2csv.transforms; const JSON2CSVParser = json2csv.Parser; @@ -48,8 +46,8 @@ program .parse(process.argv); function makePathAbsolute(filePath) { - return (filePath && !isAbsolutePath(filePath)) - ? joinPath(process.cwd(), filePath) + return (filePath && !isAbsolute(filePath)) + ? join(process.cwd(), filePath) : filePath; } diff --git a/test/CLI.js b/test/CLI.js index 3a1ad57b..83cd7a3c 100644 --- a/test/CLI.js +++ b/test/CLI.js @@ -15,9 +15,8 @@ const rmdirAsync = promisify(rmdir); const cli = `node "${joinPath(process.cwd(), './bin/json2csv.js')}"`; -const resultsPath = joinPath(process.cwd(), './test/fixtures/results'); -const getFixturePath = fixture => joinPath(process.cwd(), './test/fixtures', fixture); -// const readFile = (filePath) => readFileAsync(filePath.slice(1, filePath.length - 1), 'utf8'); +const resultsPath = './test/fixtures/results'; +const getFixturePath = fixture => joinPath('./test/fixtures', fixture); module.exports = (testRunner, jsonFixtures, csvFixtures) => { testRunner.addBefore(async () => {