Skip to content

Commit

Permalink
Merge branch '4.x'
Browse files Browse the repository at this point in the history
# Conflicts:
#	components/bower.json
#	components/handlebars.js.nuspec
#	components/package.json
#	package.json
  • Loading branch information
nknapp committed Apr 13, 2019
2 parents 1b04524 + 10b5fcf commit 2f681d2
Show file tree
Hide file tree
Showing 25 changed files with 9,111 additions and 23 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -3,6 +3,7 @@ before_install:
- npm install -g grunt-cli
script:
- grunt --stack travis
- multi-nodejs-test/run-tests.sh 0.10 0.12 4 5 6 7 8 9 10 11
email:
on_failure: change
on_success: never
Expand Down
19 changes: 15 additions & 4 deletions Gruntfile.js
Expand Up @@ -12,7 +12,8 @@ module.exports = function(grunt) {
'bench/**/*.js',
'tasks/**/*.js',
'lib/**/!(*.min|parser).js',
'spec/**/!(*.amd|json2|require).js'
'spec/**/!(*.amd|json2|require).js',
'multi-nodejs-test/*.js'
]
},

Expand Down Expand Up @@ -122,8 +123,8 @@ module.exports = function(grunt) {
browsers: [
{browserName: 'chrome'},
{browserName: 'firefox', platform: 'Linux'},
{browserName: 'safari', version: 9, platform: 'OS X 10.11'},
{browserName: 'safari', version: 8, platform: 'OS X 10.10'},
// {browserName: 'safari', version: 9, platform: 'OS X 10.11'},
// {browserName: 'safari', version: 8, platform: 'OS X 10.10'},
{browserName: 'internet explorer', version: 11, platform: 'Windows 8.1'},
{browserName: 'internet explorer', version: 10, platform: 'Windows 8'}
]
Expand All @@ -143,6 +144,14 @@ module.exports = function(grunt) {
}
},

bgShell: {
checkTypes: {
cmd: 'npm run checkTypes',
bg: false,
fail: true
}
},

watch: {
scripts: {
options: {
Expand All @@ -158,6 +167,7 @@ module.exports = function(grunt) {
// Build a new version of the library
this.registerTask('build', 'Builds a distributable version of the current project', [
'eslint',
'bgShell:checkTypes',
'parser',
'node',
'globals']);
Expand All @@ -176,14 +186,15 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-babel');
grunt.loadNpmTasks('grunt-bg-shell');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-saucelabs');
grunt.loadNpmTasks('grunt-webpack');

grunt.task.loadTasks('tasks');

grunt.registerTask('bench', ['metrics']);
grunt.registerTask('sauce', [] /* process.env.SAUCE_USERNAME ? ['tests', 'connect', 'saucelabs-mocha'] : [] */);
grunt.registerTask('sauce', process.env.SAUCE_USERNAME ? ['tests', 'connect', 'saucelabs-mocha'] : []);

grunt.registerTask('travis', process.env.PUBLISH ? ['default', 'sauce', 'metrics', 'publish:latest'] : ['default']);

Expand Down
2 changes: 1 addition & 1 deletion bench/dist-size.js
@@ -1,4 +1,4 @@
var async = require('async'),
var async = require('neo-async'),
fs = require('fs'),
zlib = require('zlib');

Expand Down
2 changes: 1 addition & 1 deletion lib/handlebars/base.js
Expand Up @@ -4,7 +4,7 @@ import {registerDefaultHelpers} from './helpers';
import {registerDefaultDecorators} from './decorators';
import logger from './logger';

export const VERSION = '4.1.0';
export const VERSION = '4.1.2';
export const COMPILER_REVISION = 7;

export const REVISION_CHANGES = {
Expand Down
2 changes: 1 addition & 1 deletion lib/handlebars/compiler/helpers.js
Expand Up @@ -24,7 +24,7 @@ export function SourceLocation(source, locInfo) {

export function id(token) {
if (/^\[.*\]$/.test(token)) {
return token.substr(1, token.length - 2);
return token.substring(1, token.length - 1);
} else {
return token;
}
Expand Down
8 changes: 7 additions & 1 deletion lib/handlebars/helpers/lookup.js
@@ -1,5 +1,11 @@
export default function(instance) {
instance.registerHelper('lookup', function(obj, field) {
return obj && obj[field];
if (!obj) {
return obj;
}
if (field === 'constructor' && !obj.propertyIsEnumerable(field)) {
return undefined;
}
return obj[field];
});
}
2 changes: 1 addition & 1 deletion lib/precompiler.js
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
import Async from 'async';
import Async from 'neo-async';
import fs from 'fs';
import * as Handlebars from './handlebars';
import {basename} from 'path';
Expand Down
114 changes: 114 additions & 0 deletions multi-nodejs-test/.eslintrc.js
@@ -0,0 +1,114 @@
module.exports = {
"extends": "eslint:recommended",
"globals": {
"self": false
},
"env": {
"node": true
},
"rules": {
// overrides eslint:recommended defaults
"no-sparse-arrays": "off",
"no-func-assign": "off",
"no-console": "off",
"no-debugger": "warn",
"no-unreachable": "warn",

// Possible Errors //
//-----------------//
"no-unsafe-negation": "error",


// Best Practices //
//----------------//
"curly": "error",
"default-case": "warn",
"dot-notation": ["error", { "allowKeywords": false }],
"guard-for-in": "warn",
"no-alert": "error",
"no-caller": "error",
"no-div-regex": "warn",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-floating-decimal": "error",
"no-implied-eval": "error",
"no-iterator": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-multi-spaces": "error",
"no-multi-str": "warn",
"no-global-assign": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-process-env": "error",
"no-proto": "error",
"no-return-assign": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-throw-literal": "error",
"no-unused-expressions": "error",
"no-warning-comments": "warn",
"no-with": "error",
"radix": "error",
"wrap-iife": "error",


// Variables //
//-----------//
"no-catch-shadow": "error",
"no-label-var": "error",
"no-shadow-restricted-names": "error",
"no-undef-init": "error",
"no-use-before-define": ["error", "nofunc"],


// Stylistic Issues //
//------------------//
"comma-dangle": ["error", "never"],
"quote-props": ["error", "as-needed", { "keywords": true, "unnecessary": false }],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"camelcase": "error",
"comma-spacing": ["error", { "before": false, "after": true }],
"comma-style": ["error", "last"],
"consistent-this": ["warn", "self"],
"eol-last": "error",
"func-style": ["error", "declaration"],
"key-spacing": ["error", {
"beforeColon": false,
"afterColon": true
}],
"new-cap": "error",
"new-parens": "error",
"no-array-constructor": "error",
"no-lonely-if": "error",
"no-mixed-spaces-and-tabs": "error",
"no-nested-ternary": "warn",
"no-new-object": "error",
"no-spaced-func": "error",
"no-trailing-spaces": "error",
"no-extra-parens": ["error", "functions"],
"quotes": ["error", "single", "avoid-escape"],
"semi": "error",
"semi-spacing": ["error", { "before": false, "after": true }],
"keyword-spacing": "error",
"space-before-blocks": ["error", "always"],
"space-before-function-paren": ["error", { "anonymous": "never", "named": "never" }],
"space-in-parens": ["error", "never"],
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": ["error", "always", { "markers": [","] }],
"wrap-regex": "warn",

// ECMAScript 6 //
//--------------//
"no-var": "off"
},
"parserOptions": {
"sourceType": "module"
}
}
1 change: 1 addition & 0 deletions multi-nodejs-test/expected.txt
@@ -0,0 +1 @@
Author: Yehuda
13 changes: 13 additions & 0 deletions multi-nodejs-test/run-handlebars.js
@@ -0,0 +1,13 @@
// This test should run with node 0.10 as long as Handlebars has been compiled before
var Handlebars = require('../');
var fs = require('fs');

console.log('Testing build Handlebars with Node version ' + process.version);
var template = fs.readFileSync(require.resolve('./template.txt.hbs'), 'utf-8');
var compiledOutput = Handlebars.compile(template)({author: 'Yehuda'}).trim();
var expectedOutput = fs.readFileSync(require.resolve('./expected.txt'), 'utf-8').trim();

if (compiledOutput !== expectedOutput) {
throw new Error('Compiled output (' + compiledOutput + ') did not match expected output (' + expectedOutput + ')');
}
console.log('Success');
21 changes: 21 additions & 0 deletions multi-nodejs-test/run-tests.sh
@@ -0,0 +1,21 @@
#!/bin/bash

cd "$( dirname "$( readlink -f "$0" )" )"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

# This script tests with precompiler and the built distribution with multiple NodeJS version.
# The rest of the travis-build will only work with newer NodeJS versions, because the build
# tools don't support older versions.
# However, the built distribution should work with older NodeJS versions as well.
# This test is simple by design. It merely ensures, that calling Handlebars does not fail with old versions.
# It does (almost) not test for correctness, because that is already done in the mocha-tests.
# And it does not use any NodeJS based testing framwork to make this part independent of the Node version.

# A list of NodeJS versions is expected as cli-args
echo "Handlebars should be able to run in various versions of NodeJS"
for i in "$@" ; do
nvm install "$i"
nvm exec "$i" node ./run-handlebars.js >/dev/null || exit 1
nvm exec "$i" node ../bin/handlebars template.txt.hbs >/dev/null || exit 1
echo Success
done
1 change: 1 addition & 0 deletions multi-nodejs-test/template.txt.hbs
@@ -0,0 +1 @@
Author: {{author}}

0 comments on commit 2f681d2

Please sign in to comment.