Skip to content

Commit

Permalink
v4.1.0. Bugfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Apr 10, 2017
1 parent 8d7bc24 commit 0e913a9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# History

## v4.1.0 2017 April 10
- Updated base files
- `cson2json` and `json2cson` will now output the error if the input file is invalid
- Closes [issue #78](https://github.com/bevry/cson/issues/78)

## v4.0.0 2016 October 20
- `parseCSString` no longer creates the `sandbox` variable if it was missing, the responsibility of such things should be, and now is, handled via the eval function of coffeescript which is what that method uses
- This is a major breaking change as parsing coffeescript files will now by default run still in a virtual machine but now in the global context rather than their own context
Expand Down
2 changes: 1 addition & 1 deletion bin/cson2json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require(require('path').join(__dirname, '..', 'es5', 'cli.js'))
require('../es5/cli')
2 changes: 1 addition & 1 deletion bin/json2cson
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require(require('path').join(__dirname, '..', 'es5', 'cli.js'))
require('../es5/cli')
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "CSON",
"name": "cson",
"version": "4.0.0",
"version": "4.1.0",
"description": "CoffeeScript-Object-Notation Parser. Same as JSON but for CoffeeScript objects.",
"homepage": "https://github.com/bevry/cson",
"license": "MIT",
Expand Down
30 changes: 22 additions & 8 deletions source/cli.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,19 @@ else
# File conversion
if process.argv.length is 3
filePath = process.argv[2]
process.stdout.write(
if conversion is 'cson2json'
CSON.createJSONString CSON.parseCSONFile(filePath), opts
else
CSON.createCSONString CSON.parseJSONFile(filePath), opts
)

if conversion is 'cson2json'
parse = CSON.parseCSONFile.bind(CSON)
create = CSON.createJSONString.bind(CSON)
else
parse = CSON.parseJSONFile.bind(CSON)
create = CSON.createCSONString.bind(CSON)

result = parse(filePath)
throw result if result instanceof Error
result = create(result, opts)
throw result if result instanceof Error
process.stdout.write(result)

# Try STDIN
else if process.argv.length is 2
Expand All @@ -77,9 +84,16 @@ else if process.argv.length is 2

processData = ->
if conversion is 'cson2json'
result = CSON.createJSONString CSON.parseCSONString(data), opts
parse = CSON.parseCSONString.bind(CSON)
create = CSON.createJSONString.bind(CSON)
else
result = CSON.createCSONString CSON.parseJSONString(data), opts
parse = CSON.parseJSONString.bind(CSON)
create = CSON.createCSONString.bind(CSON)

result = parse(data)
throw result if result instanceof Error
result = create(result, opts)
throw result if result instanceof Error
process.stdout.write(result)

# Timeout if we don't have stdin
Expand Down

0 comments on commit 0e913a9

Please sign in to comment.