Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
fix: strict comparison
Browse files Browse the repository at this point in the history
PR-URL: #2
Credit: @bl00mber
Close: #2
Reviewed-by: @isaacs
  • Loading branch information
bl00mber authored and isaacs committed Sep 30, 2019
1 parent d8ad1ee commit 0c5675f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -7,7 +7,8 @@ const CRLF = '\r\n'
const LF = '\n'

function stringifyPackage (data, indent, newline) {
const json = JSON.stringify(data, null, indent || DEFAULT_INDENT)
indent = indent || (indent === 0 ? 0 : DEFAULT_INDENT)
const json = JSON.stringify(data, null, indent)

if (newline === CRLF) {
return json.replace(/\n/g, CRLF) + CRLF
Expand Down
11 changes: 11 additions & 0 deletions test/nonformatted.js
@@ -0,0 +1,11 @@
'use strict'

const stringifyPackage = require('../index')
const test = require('tap').test

const dummy = { name: 'dummy' }

test('stringify-package', function (t) {
t.equal(stringifyPackage(dummy, 0).split(/\r\n|\r|\n/).length, 2, '0 works')
t.end()
})

0 comments on commit 0c5675f

Please sign in to comment.