File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ import program from 'commander'
4+ import { compareLiquidTags } from '../../lib/liquid-tags/tokens.js'
5+ import languages from '../../lib/languages.js'
6+
7+ program
8+ . argument ( '<files...>' , 'The file name(s) without the language dir. \nI.E. content/foo.md' )
9+ . description ( 'Shows the differences of liquid tags between two files' )
10+ . requiredOption ( '-l, --language <language>' , `Choose one of these languages to compare: ${ Object . keys ( languages ) . filter ( l => l !== 'en' ) } ` )
11+ . parse ( process . argv )
12+
13+ function reportFileDifference ( diff ) {
14+ console . log ( `File: ${ diff . file } ` )
15+ console . log ( `Translation: ${ diff . translation } ` )
16+ console . log ( `Differences:` )
17+ console . log ( diff . diff . output )
18+ }
19+
20+ function main ( ) {
21+ const files = program . args
22+ const options = program . opts ( )
23+
24+ files . forEach ( ( file ) => {
25+ const language = languages [ options . language ]
26+ if ( ! language ) throw new Error ( `${ options . language } is not a recognized language` )
27+ const diff = compareLiquidTags ( file , language )
28+ reportFileDifference ( diff )
29+ } )
30+ }
31+
32+ main ( )
You can’t perform that action at this time.
0 commit comments