Skip to content

Commit

Permalink
Merge pull request #198 from kabalin/MDLSITE-5739-master
Browse files Browse the repository at this point in the history
 MDLSITE-5739 mustache_lint: error when running on openjdk11
  • Loading branch information
stronk7 authored Jul 27, 2019
2 parents 058fd2e + 28b43e8 commit 99fec69
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist: xenial

language: php

sudo: false
Expand All @@ -6,12 +8,14 @@ addons:
apt:
packages:
- bc
- openjdk-8-jre-headless

cache:
directories:
- $HOME/cachedir

services:
- mysql

php:
- 7.1

Expand Down
2 changes: 1 addition & 1 deletion mustache_lint/mustache_lint.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function check_html_validation($content) {
if (strpos($content, '<head>') === false) {
// Primative detection if we have full html body, if not, wrap it.
// (This isn't bulletproof, obviously).
$wrappedcontent = "<!DOCTYPE html><head><title>Validate</title></head><body>\n{$content}\n</body></html>";
$wrappedcontent = "<!DOCTYPE html><html lang=\"en\"><head><title>Validate</title></head><body>\n{$content}\n</body></html>";
} else {
$wrappedcontent = $content;
}
Expand Down
8 changes: 5 additions & 3 deletions mustache_lint/mustache_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
validator=${validator:-"https://html5.validator.nu"}
if [ -f "$mydir/../node_modules/vnu-jar/build/dist/vnu.jar" ]
then
if java -version 2>&1 >/dev/null | grep -q "java version"
if java -version 2>&1 >/dev/null | grep -Eq "(java|openjdk) version"
then
javaversion=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')
if [[ "$javaversion" > "1.8" ]]
# Extract major and minor digits of version and compare it as float
# numbers. Not error proof, but sufficient to ensure it is >= 1.8
javaversion=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/')
if [ $( echo "${javaversion} >= 1.8" | bc ) == 1 ]
then
echo "NPM installed validator found."
validator="$( cd $mydir/../node_modules/ && pwd)/vnu-jar/build/dist/vnu.jar"
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"description": "Tools for CI with Moodle",
"private": true,
"dependencies": {
"vnu-jar": "^17.3.0"
"vnu-jar": "18.11.5"
}
}
2 changes: 1 addition & 1 deletion tests/fixtures/31-mustache_lint-full-html-body.patch
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ index 0000000..386ffb0
+ }
+}}
+<!DOCTYPE html>
+<html>
+<html lang="en">
+<head>
+<title>Test page</title>
+</head>
Expand Down

0 comments on commit 99fec69

Please sign in to comment.