File tree Expand file tree Collapse file tree 4 files changed +49
-3
lines changed Expand file tree Collapse file tree 4 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -35,9 +35,18 @@ module.exports = {
35
35
"padded-blocks" : "off" ,
36
36
"prefer-arrow-callback" : "off" ,
37
37
"prefer-destructuring" : "off" ,
38
+ "prefer-template" : "off" ,
38
39
"quote-props" : "off" ,
39
40
"require-unicode-regexp" : "off" ,
40
41
"sort-keys" : "off" ,
41
42
"vars-on-top" : "off"
42
- }
43
+ } ,
44
+
45
+ overrides : [ {
46
+ files : "cli.js" ,
47
+ rules : {
48
+ "no-console" : "off" ,
49
+ "no-process-exit" : "off"
50
+ }
51
+ } ]
43
52
} ;
Original file line number Diff line number Diff line change @@ -13,10 +13,10 @@ Parser is available as [NPM package](https://www.npmjs.com/package/tc-string-par
13
13
### NodeJS (>=5.10.0)
14
14
15
15
``` js
16
- const TCStringParse = require (' tc-string-parse' );
16
+ const tcStringParse = require (' tc-string-parse' );
17
17
18
18
const consentString = ' ' ; // your consent string
19
- const consentModel = TCStringParse (consentString);
19
+ const consentModel = tcStringParse (consentString);
20
20
```
21
21
22
22
### Browser (IE 9+ with [ atob polyfill] ( https://caniuse.com/#feat=atob-btoa ) )
@@ -29,3 +29,9 @@ const consentModel = TCStringParse(consentString);
29
29
var consentModel = TCStringParse (consentString);
30
30
</script >
31
31
```
32
+
33
+ ### Command line
34
+
35
+ ``` shell
36
+ tc-string-parse < your consent string>
37
+ ```
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env node
2
+
3
+ "use strict" ;
4
+
5
+ var args = process . argv . slice ( 2 ) ;
6
+
7
+ if ( ! args . length ) {
8
+ console . error ( "Transparency and consent string not passed." ) ;
9
+ process . exit ( 1 ) ;
10
+ }
11
+
12
+ if ( args . length !== 1 ) {
13
+ console . error ( "Too many arguments passed." ) ;
14
+ process . exit ( 1 ) ;
15
+ }
16
+
17
+ var parse = require ( "." ) ;
18
+
19
+ var model = { } ;
20
+ try {
21
+ model = parse ( args [ 0 ] ) ;
22
+ } catch ( error ) {
23
+ console . error ( "Unable to parse constent string: " + error . message ) ;
24
+ process . exit ( 1 ) ;
25
+ }
26
+
27
+ var output = JSON . stringify ( model , null , 2 ) ;
28
+
29
+ console . log ( output ) ;
30
+ process . exit ( 0 ) ;
Original file line number Diff line number Diff line change 16
16
],
17
17
"license" : " Apache-2.0" ,
18
18
"main" : " tc-string-parse.js" ,
19
+ "bin" : " ./cli.js" ,
19
20
"scripts" : {
20
21
"test" : " ava --verbose" ,
21
22
"lint" : " eslint ." ,
You can’t perform that action at this time.
0 commit comments