Skip to content

Commit d0caf8b

Browse files
committed
unique array values only
1 parent a3dad97 commit d0caf8b

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

.gitattributes

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
*.html text diff=html
5+
*.css text
6+
*.less text
7+
*.js text
8+
*.ts text
9+
*.json text
10+
11+
# Denote all files that are truly binary and should not be modified.
12+
*.png binary
13+
*.jpg binary
14+
15+
# absolute paths are ok, as are globs
16+
/**/postinst* text eol=lf
17+
18+
# paths that don't start with / are treated relative to the .gitattributes folder
19+
relative/path/*.txt text eol=lf

lib/build/parser/actions.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ function doAction(type, isArray, actionValue, result, line, _a) {
66
if (result.chapters[chapter].pages[page].tasks[task][type] === undefined) {
77
result.chapters[chapter].pages[page].tasks[task][type] = [];
88
}
9+
var current = result.chapters[chapter].pages[page].tasks[task][type];
910
if (!!isArray) {
10-
var values = cleanup_1.trimArray(actionValue);
11-
values.forEach(function (value) {
12-
result.chapters[chapter].pages[page].tasks[task][type].push(value);
11+
var values_1 = cleanup_1.trimArray(actionValue);
12+
values_1.forEach(function (value) {
13+
if (current.indexOf(value) === -1 && values_1.indexOf(value) === -1) {
14+
result.chapters[chapter].pages[page].tasks[task][type].push(value);
15+
}
1316
});
1417
}
1518
else {
16-
result.chapters[chapter].pages[page].tasks[task][type].push(actionValue);
19+
if (current.indexOf(actionValue) === -1) {
20+
result.chapters[chapter].pages[page].tasks[task][type].push(actionValue);
21+
}
1722
}
1823
return result;
1924
}

lib/cli.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#! /usr/bin/env node
2-
32
"use strict";
43
var program = require('commander');
54
var chalk = require('chalk');

src/build/parser/actions.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@ function doAction(type: CR.OutputAction, isArray, actionValue, result, line, {ch
88
if (result.chapters[chapter].pages[page].tasks[task][type] === undefined) {
99
result.chapters[chapter].pages[page].tasks[task][type] = [];
1010
}
11+
let current = result.chapters[chapter].pages[page].tasks[task][type];
1112
if (!!isArray) {
1213
// array
1314
let values = trimArray(actionValue);
1415
values.forEach((value) => {
15-
result.chapters[chapter].pages[page].tasks[task][type].push(value);
16+
if (current.indexOf(value) === -1 && values.indexOf(value) === -1) {
17+
result.chapters[chapter].pages[page].tasks[task][type].push(value);
18+
}
1619
});
1720
} else {
1821
// string
19-
result.chapters[chapter].pages[page].tasks[task][type].push(actionValue);
22+
if (current.indexOf(actionValue) === -1) {
23+
result.chapters[chapter].pages[page].tasks[task][type].push(actionValue);
24+
}
2025
}
2126
return result;
2227
}

0 commit comments

Comments
 (0)