Skip to content

Commit ad24f08

Browse files
authored
Migrate src->lib, add coveralls, fix mrodrig/json-2-csv-cli#4 (#172)
Migrate src directory to lib directory to follow best practices Adds .coveralls.yml to .npmignore Fixes: mrodrig/json-2-csv-cli#4
1 parent 327008e commit ad24f08

File tree

12 files changed

+19
-15
lines changed

12 files changed

+19
-15
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ coverage
99
upgrade_guides
1010
tslint.json
1111
_config.yml
12+
.coveralls.yml
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/utils.js renamed to lib/utils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ module.exports = {
3939
function buildOptions(opts) {
4040
opts = {...constants.defaultOptions, ...opts || {}};
4141

42-
// Note: Object.assign does a shallow default, we need to deep copy the delimiter object
43-
opts.delimiter = {...constants.defaultOptions.delimiter, ...opts.delimiter};
42+
// Copy the delimiter fields over since the spread operator does a shallow copy
43+
opts.delimiter.field = opts.delimiter.field || constants.defaultOptions.delimiter.field;
44+
opts.delimiter.wrap = opts.delimiter.wrap || constants.defaultOptions.delimiter.wrap;
45+
opts.delimiter.eol = opts.delimiter.eol || constants.defaultOptions.delimiter.eol;
4446

4547
// Otherwise, send the options back
4648
return opts;

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@
55
},
66
"name": "json-2-csv",
77
"description": "A JSON to CSV and CSV to JSON converter that natively supports sub-documents and auto-generates the CSV heading.",
8-
"version": "3.7.12",
8+
"version": "3.7.13",
9+
"homepage": "https://mrodrig.github.io/json-2-csv",
910
"repository": {
1011
"type": "git",
1112
"url": "https://github.com/mrodrig/json-2-csv.git"
1213
},
1314
"bugs": {
1415
"url": "https://github.com/mrodrig/json-2-csv/issues"
1516
},
16-
"main": "./src/converter.js",
17-
"types": "./src/converter.d.ts",
17+
"main": "lib/converter.js",
18+
"types": "./lib/converter.d.ts",
1819
"scripts": {
1920
"test": "mocha test/tests.js",
2021
"coverage": "nyc --reporter=lcov --reporter=text-summary --reporter=text _mocha",
2122
"coveralls": "nyc report --reporter=text-lcov | coveralls",
2223
"lint": "npm run lint:eslint && npm run lint:tslint",
23-
"lint:eslint": "eslint src test",
24-
"lint:tslint": "tslint -c tslint.json 'src/**/*.ts'"
24+
"lint:eslint": "eslint lib test",
25+
"lint:tslint": "tslint -c tslint.json 'lib/**/*.ts'"
2526
},
2627
"keywords": [
2728
"json",

test/csv2json.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "should" }]*/
44

55
let should = require('should'),
6-
converter = require('../src/converter'),
7-
constants = require('../src/constants'),
8-
utils = require('../src/utils'),
6+
converter = require('../lib/converter'),
7+
constants = require('../lib/constants'),
8+
utils = require('../lib/utils'),
99
defaultOptions = constants.defaultOptions;
1010

1111
function runTests(jsonTestData, csvTestData) {

0 commit comments

Comments
 (0)