Skip to content

Commit 4078e21

Browse files
committed
Merge branch 'master' into release/v5.0.0
2 parents ca19d16 + 9515d3c commit 4078e21

File tree

5 files changed

+81
-3
lines changed

5 files changed

+81
-3
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: NSS-5.0.0 Regressions
3+
about: To report regressions in 5.0.0 (i.e. things that used to work in earlier releases),
4+
use this template
5+
title: ''
6+
labels: ''
7+
assignees: ''
8+
9+
---
10+
11+
## Please describe what you did in reproducible steps
12+
13+
14+
## How did it work with 4.x series servers?
15+
16+
17+
## What happened when you tried the same with the 5.0.0 beta?
18+
19+
20+
## Any material that will help, logs, error messages, etc.

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ install:
2323
script:
2424
# Test the code
2525
- npm run standard
26+
- npm run validate
2627
- npm run nyc
2728
# Test global install of the package
2829
- npm pack .

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,23 @@
118118
"nock": "^9.0.14",
119119
"node-mocks-http": "^1.7.0",
120120
"nyc": "^13.0.1",
121+
"randombytes": "^2.0.1",
121122
"sinon": "^2.1.0",
122123
"sinon-chai": "^2.8.0",
123124
"snyk": "^1.88.2",
124125
"standard": "^8.6.0",
125126
"supertest": "^3.0.0",
126-
"whatwg-url": "^6.1.0",
127-
"randombytes": "^2.0.1"
127+
"turtle-validator": "^1.0.2",
128+
"whatwg-url": "^6.1.0"
128129
},
129130
"main": "index.js",
130131
"scripts": {
131132
"solid": "node ./bin/solid",
132133
"standard": "standard '{bin,examples,lib,test}/**/*.js'",
134+
"validate": "node ./test/validate-turtle.js",
133135
"nyc": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 nyc --reporter=text-summary mocha",
134136
"mocha": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 mocha",
135-
"test": "npm run standard && npm run nyc",
137+
"test": "npm run standard && npm run validate && npm run nyc",
136138
"clean": "rimraf config/templates config/views"
137139
},
138140
"nyc": {

test/validate-turtle.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
const fs = require('fs')
3+
const Handlebars = require('handlebars')
4+
const path = require('path')
5+
const validate = require('turtle-validator/lib/validator')
6+
7+
const regex = new RegExp('\\.(acl|ttl)$', 'i')
8+
const substitutions = {
9+
webId: 'http://example.com/#me',
10+
11+
name: 'Test test'
12+
}
13+
14+
const files = recursiveFiles(path.join(__dirname, '../default-templates/'))
15+
16+
for (const file of files) {
17+
const data = fs.readFileSync(file, 'utf8')
18+
const template = Handlebars.compile(data)
19+
validate(template(substitutions), feedback => {
20+
if (feedback.errors.length > 0) {
21+
throw new Error(`Validation error in ${file}: ${feedback.errors[0]}`)
22+
}
23+
})
24+
}
25+
26+
function recursiveFiles (dir) {
27+
const content = fs.readdirSync(dir)
28+
return [].concat(...content.map(file => {
29+
const fullPath = path.join(dir, file)
30+
const stat = fs.statSync(fullPath)
31+
if (stat.isDirectory()) {
32+
return recursiveFiles(fullPath)
33+
} else if (regex.test(file)) {
34+
return [fullPath]
35+
}
36+
return []
37+
}))
38+
}

0 commit comments

Comments
 (0)