Skip to content

Commit 06079e8

Browse files
authored
fix(cli): fix relative paths issue in CLI when not streaming (#488)
1 parent c984851 commit 06079e8

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

bin/json2csv.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ const TablePrinter = require('./utils/TablePrinter');
1414

1515
const readFile = promisify(readFileOrig);
1616
const writeFile = promisify(writeFileOrig);
17-
const isAbsolutePath = promisify(isAbsolute);
18-
const joinPath = promisify(join);
1917

2018
const { unwind, flatten } = json2csv.transforms;
2119
const JSON2CSVParser = json2csv.Parser;
@@ -48,8 +46,8 @@ program
4846
.parse(process.argv);
4947

5048
function makePathAbsolute(filePath) {
51-
return (filePath && !isAbsolutePath(filePath))
52-
? joinPath(process.cwd(), filePath)
49+
return (filePath && !isAbsolute(filePath))
50+
? join(process.cwd(), filePath)
5351
: filePath;
5452
}
5553

test/CLI.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ const rmdirAsync = promisify(rmdir);
1515

1616
const cli = `node "${joinPath(process.cwd(), './bin/json2csv.js')}"`;
1717

18-
const resultsPath = joinPath(process.cwd(), './test/fixtures/results');
19-
const getFixturePath = fixture => joinPath(process.cwd(), './test/fixtures', fixture);
20-
// const readFile = (filePath) => readFileAsync(filePath.slice(1, filePath.length - 1), 'utf8');
18+
const resultsPath = './test/fixtures/results';
19+
const getFixturePath = fixture => joinPath('./test/fixtures', fixture);
2120

2221
module.exports = (testRunner, jsonFixtures, csvFixtures) => {
2322
testRunner.addBefore(async () => {

0 commit comments

Comments
 (0)