Skip to content

Commit 9bcedd5

Browse files
authored
Merge pull request #9 from github/test-prose
Add prose tests
2 parents 571055e + 03d6c32 commit 9bcedd5

File tree

7 files changed

+98
-3
lines changed

7 files changed

+98
-3
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
.DS_Store
2-
.jekyll-metadata
31
_site/
42
.bundle
3+
.DS_Store
4+
.jekyll-metadata
55
bin
6+
node_modules
67
vendor

_config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ baseurl: "/open-source-handbook"
22

33
exclude:
44
- bin
5+
- CONTRIBUTING.md
56
- docs
67
- Gemfile*
8+
- node_modules
9+
- package.json
710
- Rakefile
811
- README.md
912
- script

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "open-source-handbook",
3+
"private": true,
4+
"scripts": {
5+
"test": "script/test"
6+
},
7+
"devDependencies": {
8+
"async": "^1.5.2",
9+
"glob": "^7.0.5",
10+
"ignore": "^3.1.3",
11+
"js-yaml": "^3.6.1",
12+
"remark-lint": "^4.0.1",
13+
"remark-parse": "^1.0.0",
14+
"remark-retext": "^2.0.0",
15+
"remark-stringify": "^1.0.0",
16+
"retext": "^3.0.0",
17+
"retext-english": "^2.0.0",
18+
"retext-equality": "^2.3.2",
19+
"retext-readability": "^2.0.0",
20+
"retext-simplify": "^2.0.0",
21+
"to-vfile": "^1.0.0",
22+
"unified": "^4.1.2",
23+
"vfile-reporter": "^2.0.0"
24+
}
25+
}

script/bootstrap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ echo "==> Installing gem dependencies…"
77
bundle check --path vendor/gems 2>&1 > /dev/null || {
88
time bundle install --binstubs bin --path vendor/gems
99
}
10+
11+
echo "==> Installing node dependencies…"
12+
npm install

script/cibuild

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
set -e
44

5-
export PATH="/usr/share/rbenv/shims:$PATH"
5+
export PATH="/usr/share/rbenv/shims:/usr/local/share/nodenv/shims:$PATH"
66
export RBENV_VERSION="2.1.7-github"
7+
export NODENV_VERSION="v0.10.21"
78
# clean out the ruby environment
89
export RUBYLIB=
910
export RUBYOPT=

script/test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ set -e
55
script/build --config _config.yml,test/_config.yml
66
bundle exec rake
77
script/html-proofer
8+
script/test-prose

script/test-prose

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env node
2+
3+
// Retext stuff
4+
var unified = require('unified');
5+
6+
// Remark stuff
7+
var parse = require('remark-parse');
8+
var lint = require('remark-lint');
9+
var remark2retext = require('remark-retext');
10+
var stringify = require('remark-stringify');
11+
12+
// Util stuff
13+
var report = require('vfile-reporter');
14+
var glob = require('glob');
15+
var fs = require('fs');
16+
var async = require('async');
17+
var yaml = require('js-yaml');
18+
var jekyllConfig = yaml.safeLoad(fs.readFileSync('_config.yml', 'utf8'));
19+
var ignore = require('ignore')().add(jekyllConfig["exclude"])
20+
21+
var options = {
22+
// https://github.com/wooorm/remark-lint/blob/master/doc/rules.md
23+
"lint": {
24+
"list-item-indent": "space", // As the gods intended.
25+
"maximum-line-length": false, // turn off line length linting
26+
"no-html": false, // Sadly, need HTML for video embeds
27+
"no-heading-punctuation": false,
28+
"list-item-spacing": false,
29+
},
30+
"readability": {
31+
"age": 18
32+
},
33+
"simplify": {
34+
ignore: [
35+
"modify",
36+
"contribute",
37+
"previous"
38+
]
39+
}
40+
};
41+
42+
async.map(ignore.filter(glob.sync("**/*.md")), function(file, callback) {
43+
fs.readFile(file, function(err, contents) {
44+
unified()
45+
.use(parse)
46+
.use(lint, options["lint"])
47+
// .use(remark2retext, unified()
48+
// .use(require('retext-english'))
49+
// .use(require('retext-simplify'), options["simplify"])
50+
// .use(require('retext-equality'))
51+
// .use(require('retext-readability'), options["readability"])
52+
// )
53+
.use(stringify)
54+
.process(contents.toString(), function (err, result) {
55+
result.filename = file;
56+
callback(err, result);
57+
});
58+
});
59+
}, function (err, results) {
60+
console.log(report(results));
61+
});

0 commit comments

Comments
 (0)