Skip to content

Commit

Permalink
Merge pull request #24 from IWSLLC/issue-23
Browse files Browse the repository at this point in the history
updating dependencies, fixing 23; also fixes undefined columns
  • Loading branch information
nathanb committed Mar 26, 2017
2 parents 40862a0 + daeae70 commit d7c46ea
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
node_js:
- '5'
- '4'
- '7'
- '6'
- '0.10'
script: "mocha"
cache:
Expand Down
2 changes: 1 addition & 1 deletion exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ exporter.prototype.prepValue = function(arg, forceQuoted) {
exporter.prototype.getHeaderRow = function() {
var self = this
var header = _.reduce(self.options.fields, function(line, field) {
var label = field.label || field.field
var label = field.label || field.name
if (line === 'START') {
line = '';
} else {
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "json-csv",
"version": "1.3.0",
"version": "1.4.0",
"description": "Export a richly structured, JSON array to CSV",
"homepage": "https://github.com/IWSLLC/json-csv",
"author": "Nathan Bridgewater <info@iws.io> (http://iws.io/)",
Expand All @@ -18,9 +18,9 @@
"node": ">=0.10"
},
"devDependencies": {
"coffee-script": "^1.10.0",
"mocha": "^2.4.5",
"should": "^8.3.0"
"coffee-script": "^1.12.4",
"mocha": "^3.2.0",
"should": "^11.2.1"
},
"bugs": {
"url": "https://github.com/IWSLLC/json-csv/issues"
Expand All @@ -29,9 +29,9 @@
"test": "test"
},
"dependencies": {
"concat-stream": "^1.5.1",
"event-stream": "^3.3.2",
"lodash": "^4.7.0"
"concat-stream": "^1.6.0",
"event-stream": "^3.3.4",
"lodash": "^4.17.4"
},
"scripts": {
"test": "mocha"
Expand Down
33 changes: 33 additions & 0 deletions test/issue-23.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
jsoncsv = require '../index'
should = require "should"

describe "Issue 23", ->
describe "When excluding label definitions", ->
before (done) ->
@items = [{a: "first", b: "second"}, {a: "third", b:"fourth"}, {a: "fifth", b: "sixth"}]
jsoncsv.csvBuffered @items, {
fields: [
{name: "a", label: "a"}
{name: "b"} # this is breaking (before fix)
]}, (err, csv) =>
@csv = csv
@err = err
done()

it "should export a and b", -> @csv.should.equal "a,b\r\nfirst,second\r\nthird,fourth\r\nfifth,sixth\r\n"

#also this issue came up (because of the first one)
describe "When exporting a column that resolves undefined in the data set", ->
before (done) ->
@items = [{a: "first", b: "second"}, {a: "third", b:"fourth"}, {a: "fifth", b: "sixth"}]
jsoncsv.csvBuffered @items, {
fields: [
{name: "a"}
{name: "b"}
{name: "c"} #breaking before fix
]}, (err, csv) =>
@csv = csv
@err = err
done()

it "should export a, b, and c", -> @csv.should.equal "a,b,c\r\nfirst,second,\r\nthird,fourth,\r\nfifth,sixth,\r\n"

0 comments on commit d7c46ea

Please sign in to comment.