Skip to content

Commit

Permalink
fix(cli): fix relative paths issue in CLI when not streaming (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjoDiaz authored Sep 24, 2020
1 parent c984851 commit 06079e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 2 additions & 4 deletions bin/json2csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 2 additions & 3 deletions test/CLI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 06079e8

Please sign in to comment.