Skip to content

Commit 3a11aa5

Browse files
committed
Added lintable flag in library and cli
1 parent e668c56 commit 3a11aa5

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

bin/cli.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,21 @@ var argv = require('yargs')
2121
, default : 2
2222
, describe : 'specifying tabulation spaces'
2323
, type : 'number'
24-
})
24+
}).option('r',{
25+
alias : 'lintable'
26+
, default : false
27+
, describe : 'output valid json'
28+
, type : 'boolean'
29+
})
2530
.example('jsome -cl /some/dir/file.json', 'print out the content of file.json in color displaying indentation levels')
2631
.example('jsome -c false -l /some/dir/file.json', 'print out the content of file.json without color but with indentation levels')
2732
.help('h')
2833
.argv;
2934

30-
jsome.params.colored = argv.c;
31-
jsome.level.show = argv.l;
32-
jsome.level.spaces = argv.s;
35+
jsome.params.colored = argv.c;
36+
jsome.params.lintable = argv.r;
37+
jsome.level.show = argv.l;
38+
jsome.level.spaces = argv.s;
3339

3440
var filePath = argv._[0] || '';
3541

lib/generator.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,13 @@ module.exports = (function () {
7373
}
7474

7575
function colorifySpec (char, type, level) {
76-
return generateLevel(level) + useColorProvider('' + char, jsomeRef.colors[type]);
76+
var quote = (
77+
jsomeRef.params.lintable && type === 'attr'
78+
? colorifySpec('"', 'quot', 0)
79+
: ''
80+
)
81+
return generateLevel(level) + quote
82+
+ useColorProvider('' + char, jsomeRef.colors[type]) + quote;
7783
}
7884

7985
function useColorProvider (str, color) {

script.js

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var colors = {
2222
, params = {
2323
'colored' : true
2424
, 'async' : false
25+
, 'lintable': false
2526
}
2627

2728

0 commit comments

Comments
 (0)