Skip to content

Commit

Permalink
Nicer output format for js objects
Browse files Browse the repository at this point in the history
  • Loading branch information
kof committed May 23, 2017
1 parent 06e6632 commit 7c1c714
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
18 changes: 9 additions & 9 deletions bin/jss.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env node

var fs = require('fs')
var path = require('path')
var program = require('commander')
var util = require('util')
var converters = require('../index')
var multilinePrompt = require('../lib/multilinePrompt')
var execModule = require('../lib/execModule')
const fs = require('fs')
const path = require('path')
const program = require('commander')
const stringifyObject = require('stringify-object')
const converters = require('../index')
const multilinePrompt = require('../lib/multilinePrompt')
const execModule = require('../lib/execModule')

function list(val) {
return val.split(',').map(function(str) {
Expand Down Expand Up @@ -42,7 +42,7 @@ function convert(src) {

switch (program.format) {
case 'js':
output = util.inspect(converted, {depth: null})
output = stringifyObject(converted, {indent: ' '})
break
case 'json':
output = JSON.stringify(converted, null, 2)
Expand Down Expand Up @@ -78,7 +78,7 @@ program
console.log('Input source:')
multilinePrompt((src) => {
try {
console.log(converter({code: src}) + '\n')
console.log(convert(src) + '\n')
} catch (err) {
console.log(err.message)
}
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.0.1 / 2017-05-23

- Nicer output format for js objects

## 4.0.0 / 2017-05-23

- Added multiline source input mode --multiline
Expand Down
Binary file modified demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"dependencies": {
"commander": "^2.8.1",
"css": "^2.2.0",
"require-dir": "^0.3.0"
"require-dir": "^0.3.0",
"stringify-object": "^3.2.0"
},
"devDependencies": {
"babel": "^5.8.23"
Expand Down

0 comments on commit 7c1c714

Please sign in to comment.