forked from segmentio/segment-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathengage-compare.js
More file actions
48 lines (37 loc) · 1.11 KB
/
engage-compare.js
File metadata and controls
48 lines (37 loc) · 1.11 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
36
37
38
39
40
41
42
43
44
45
46
47
48
const path = require('path');
const fs = require('fs');
const fm = require('front-matter');
const yaml = require('js-yaml');
const Diff = require('diff')
const ora = require('ora')
const {
type
} = require('os');
const pages = yaml.load(fs.readFileSync(path.resolve(__dirname, `../src/_data/engage-compare.yml`)))
const compare = async () => {
let title = ""
let engage_path = ""
let personas_path = ""
for (const key in pages) {
title = pages[key].title
engage_path = pages[key].engage
personas_path = pages[key].personas
const throbber = ora(`${title}`).start()
const engage_article = path.resolve(engage_path)
const personas_article = path.resolve(personas_path)
try {
const e = fm(fs.readFileSync(engage_article, 'utf8')).body;
const p = fm(fs.readFileSync(personas_article, 'utf8')).body;
const diff = Diff.diffChars(p, e)
if (diff.length > 1) {
throbber.fail(`${title} has diffs!`)
} else {
throbber.succeed()
}
} catch (e) {
console.log(e)
return false
}
}
}
compare()