forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathliquid-diff.js
More file actions
executable file
·35 lines (29 loc) · 1.03 KB
/
liquid-diff.js
File metadata and controls
executable file
·35 lines (29 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env node
import program from 'commander'
import { compareLiquidTags } from '../../lib/liquid-tags/tokens.js'
import languages from '../../lib/languages.js'
program
.argument('<files...>', 'The file name(s) without the language dir. \nI.E. content/foo.md')
.description('Shows the differences of liquid tags between two files')
.requiredOption(
'-l, --language <language>',
`Choose one of these languages to compare: ${Object.keys(languages).filter((l) => l !== 'en')}`
)
.parse(process.argv)
function reportFileDifference(diff) {
console.log(`File: ${diff.file}`)
console.log(`Translation: ${diff.translation}`)
console.log(`Differences:`)
console.log(diff.diff.output)
}
function main() {
const files = program.args
const options = program.opts()
files.forEach((file) => {
const language = languages[options.language]
if (!language) throw new Error(`${options.language} is not a recognized language`)
const diff = compareLiquidTags(file, language)
reportFileDifference(diff)
})
}
main()