Skip to content

Commit

Permalink
style: reformat all files using prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
nknapp committed Dec 3, 2019
1 parent 2f0991a commit 3fb331e
Show file tree
Hide file tree
Showing 91 changed files with 5,745 additions and 2,235 deletions.
117 changes: 79 additions & 38 deletions Gruntfile.js
@@ -1,28 +1,39 @@
/* eslint-disable no-process-env */
module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

clean: ['tmp', 'dist', 'lib/handlebars/compiler/parser.js', 'integration-testing/**/node_modules'],
clean: [
'tmp',
'dist',
'lib/handlebars/compiler/parser.js',
'integration-testing/**/node_modules'
],

copy: {
dist: {
options: {
processContent: function(content) {
return grunt.template.process('/**!\n\n @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat\n <%= pkg.name %> v<%= pkg.version %>\n\n<%= grunt.file.read("LICENSE") %>\n*/\n')
+ content
+ '\n// @license-end\n';
return (
grunt.template.process(
'/**!\n\n @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat\n <%= pkg.name %> v<%= pkg.version %>\n\n<%= grunt.file.read("LICENSE") %>\n*/\n'
) +
content +
'\n// @license-end\n'
);
}
},
files: [
{expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/'}
]
files: [{ expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/' }]
},
components: {
files: [
{expand: true, cwd: 'components/', src: ['**'], dest: 'dist/components'},
{expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/components'}
{
expand: true,
cwd: 'components/',
src: ['**'],
dest: 'dist/components'
},
{ expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/components' }
]
}
},
Expand All @@ -34,12 +45,14 @@ module.exports = function(grunt) {
auxiliaryCommentBefore: 'istanbul ignore next'
},
cjs: {
files: [{
cwd: 'lib/',
expand: true,
src: '**/!(index).js',
dest: 'dist/cjs/'
}]
files: [
{
cwd: 'lib/',
expand: true,
src: '**/!(index).js',
dest: 'dist/cjs/'
}
]
}
},
webpack: {
Expand Down Expand Up @@ -72,15 +85,17 @@ module.exports = function(grunt) {
preserveComments: /(?:^!|@(?:license|preserve|cc_on))/
},
dist: {
files: [{
cwd: 'dist/',
expand: true,
src: ['handlebars*.js', '!*.min.js'],
dest: 'dist/',
rename: function(dest, src) {
return dest + src.replace(/\.js$/, '.min.js');
files: [
{
cwd: 'dist/',
expand: true,
src: ['handlebars*.js', '!*.min.js'],
dest: 'dist/',
rename: function(dest, src) {
return dest + src.replace(/\.js$/, '.min.js');
}
}
}]
]
}
},

Expand Down Expand Up @@ -108,24 +123,39 @@ module.exports = function(grunt) {
detailedError: true,
concurrency: 4,
browsers: [
{browserName: 'chrome'},
{browserName: 'firefox', platform: 'Linux'},
{ 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: 'internet explorer', version: 11, platform: 'Windows 8.1'},
{browserName: 'internet explorer', version: 10, platform: 'Windows 8'}
{
browserName: 'internet explorer',
version: 11,
platform: 'Windows 8.1'
},
{
browserName: 'internet explorer',
version: 10,
platform: 'Windows 8'
}
]
}
},
sanity: {
options: {
build: process.env.TRAVIS_JOB_ID,
urls: ['http://localhost:9999/spec/umd.html?headless=true', 'http://localhost:9999/spec/umd-runtime.html?headless=true'],
urls: [
'http://localhost:9999/spec/umd.html?headless=true',
'http://localhost:9999/spec/umd-runtime.html?headless=true'
],
detailedError: true,
concurrency: 2,
browsers: [
{browserName: 'chrome'},
{browserName: 'internet explorer', version: 10, platform: 'Windows 8'}
{ browserName: 'chrome' },
{
browserName: 'internet explorer',
version: 10,
platform: 'Windows 8'
}
]
}
}
Expand All @@ -137,7 +167,6 @@ module.exports = function(grunt) {
bg: false,
fail: true
}

},

watch: {
Expand Down Expand Up @@ -167,9 +196,9 @@ module.exports = function(grunt) {
grunt.task.loadTasks('tasks');

this.registerTask(
'build',
'Builds a distributable version of the current project',
['parser', 'node', 'globals']
'build',
'Builds a distributable version of the current project',
['parser', 'node', 'globals']
);

this.registerTask('node', ['babel:cjs']);
Expand All @@ -183,13 +212,25 @@ module.exports = function(grunt) {
]);

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'] : []
);
// Requires secret properties (saucelabs-credentials etc.) from .travis.yaml
grunt.registerTask('extensive-tests-and-publish-to-aws', ['default', 'bgShell:integrationTests', 'sauce', 'metrics', 'publish:latest']);
grunt.registerTask('extensive-tests-and-publish-to-aws', [
'default',
'bgShell:integrationTests',
'sauce',
'metrics',
'publish:latest'
]);
grunt.registerTask('on-file-change', ['build', 'concat:tests', 'test']);

// === Primary tasks ===
grunt.registerTask('dev', ['clean', 'connect', 'watch']);
grunt.registerTask('default', ['clean', 'build', 'test', 'release']);
grunt.registerTask('integration-tests', ['default', 'bgShell:integrationTests']);
grunt.registerTask('integration-tests', [
'default',
'bgShell:integrationTests'
]);
};
17 changes: 11 additions & 6 deletions bench/dist-size.js
@@ -1,12 +1,14 @@
var async = require('neo-async'),
fs = require('fs'),
zlib = require('zlib');
fs = require('fs'),
zlib = require('zlib');

module.exports = function(grunt, callback) {
var distFiles = fs.readdirSync('dist'),
distSizes = {};
distSizes = {};

async.each(distFiles, function(file, callback) {
async.each(
distFiles,
function(file, callback) {
var content;
try {
content = fs.readFileSync('dist/' + file);
Expand All @@ -32,7 +34,10 @@ module.exports = function(grunt, callback) {
});
},
function() {
grunt.log.writeln('Distribution sizes: ' + JSON.stringify(distSizes, undefined, 2));
grunt.log.writeln(
'Distribution sizes: ' + JSON.stringify(distSizes, undefined, 2)
);
callback([distSizes]);
});
}
);
};
2 changes: 1 addition & 1 deletion bench/index.js
Expand Up @@ -2,7 +2,7 @@ var fs = require('fs');

var metrics = fs.readdirSync(__dirname);
metrics.forEach(function(metric) {
if (metric === 'index.js' || !(/(.*)\.js$/.test(metric))) {
if (metric === 'index.js' || !/(.*)\.js$/.test(metric)) {
return;
}

Expand Down
13 changes: 9 additions & 4 deletions bench/precompile-size.js
@@ -1,5 +1,5 @@
var _ = require('underscore'),
templates = require('./templates');
templates = require('./templates');

module.exports = function(grunt, callback) {
// Deferring to here in case we have a build for parser, etc as part of this grunt exec
Expand All @@ -8,12 +8,17 @@ module.exports = function(grunt, callback) {
var templateSizes = {};
_.each(templates, function(info, template) {
var src = info.handlebars,
compiled = Handlebars.precompile(src, {}),
knownHelpers = Handlebars.precompile(src, {knownHelpersOnly: true, knownHelpers: info.helpers});
compiled = Handlebars.precompile(src, {}),
knownHelpers = Handlebars.precompile(src, {
knownHelpersOnly: true,
knownHelpers: info.helpers
});

templateSizes[template] = compiled.length;
templateSizes['knownOnly_' + template] = knownHelpers.length;
});
grunt.log.writeln('Precompiled sizes: ' + JSON.stringify(templateSizes, undefined, 2));
grunt.log.writeln(
'Precompiled sizes: ' + JSON.stringify(templateSizes, undefined, 2)
);
callback([templateSizes]);
};
3 changes: 2 additions & 1 deletion bench/templates/arguments.js
Expand Up @@ -8,5 +8,6 @@ module.exports = {
bar: true
},

handlebars: '{{foo person "person" 1 true foo=bar foo="person" foo=1 foo=true}}'
handlebars:
'{{foo person "person" 1 true foo=bar foo="person" foo=1 foo=true}}'
};
9 changes: 8 additions & 1 deletion bench/templates/array-each.js
@@ -1,5 +1,12 @@
module.exports = {
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}] },
context: {
names: [
{ name: 'Moe' },
{ name: 'Larry' },
{ name: 'Curly' },
{ name: 'Shemp' }
]
},
handlebars: '{{#each names}}{{name}}{{/each}}',
dust: '{#names}{name}{/names}',
mustache: '{{#names}}{{name}}{{/names}}',
Expand Down
9 changes: 8 additions & 1 deletion bench/templates/array-mustache.js
@@ -1,4 +1,11 @@
module.exports = {
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}] },
context: {
names: [
{ name: 'Moe' },
{ name: 'Larry' },
{ name: 'Curly' },
{ name: 'Shemp' }
]
},
handlebars: '{{#names}}{{name}}{{/names}}'
};
6 changes: 3 additions & 3 deletions bench/templates/complex.js
Expand Up @@ -7,9 +7,9 @@ module.exports = {
},
hasItems: true, // To make things fairer in mustache land due to no `{{if}}` construct on arrays
items: [
{name: 'red', current: true, url: '#Red'},
{name: 'green', current: false, url: '#Green'},
{name: 'blue', current: false, url: '#Blue'}
{ name: 'red', current: true, url: '#Red' },
{ name: 'green', current: false, url: '#Green' },
{ name: 'blue', current: false, url: '#Blue' }
]
},

Expand Down
9 changes: 8 additions & 1 deletion bench/templates/data.js
@@ -1,4 +1,11 @@
module.exports = {
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}] },
context: {
names: [
{ name: 'Moe' },
{ name: 'Larry' },
{ name: 'Curly' },
{ name: 'Shemp' }
]
},
handlebars: '{{#each names}}{{@index}}{{name}}{{/each}}'
};
10 changes: 9 additions & 1 deletion bench/templates/depth-1.js
@@ -1,5 +1,13 @@
module.exports = {
context: { names: [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}, {name: 'Shemp'}], foo: 'bar' },
context: {
names: [
{ name: 'Moe' },
{ name: 'Larry' },
{ name: 'Curly' },
{ name: 'Shemp' }
],
foo: 'bar'
},
handlebars: '{{#each names}}{{../foo}}{{/each}}',
mustache: '{{#names}}{{foo}}{{/names}}',
eco: '<% for item in @names: %><%= @foo %><% end %>'
Expand Down
16 changes: 13 additions & 3 deletions bench/templates/depth-2.js
@@ -1,6 +1,16 @@
module.exports = {
context: { names: [{bat: 'foo', name: ['Moe']}, {bat: 'foo', name: ['Larry']}, {bat: 'foo', name: ['Curly']}, {bat: 'foo', name: ['Shemp']}], foo: 'bar' },
handlebars: '{{#each names}}{{#each name}}{{../bat}}{{../../foo}}{{/each}}{{/each}}',
context: {
names: [
{ bat: 'foo', name: ['Moe'] },
{ bat: 'foo', name: ['Larry'] },
{ bat: 'foo', name: ['Curly'] },
{ bat: 'foo', name: ['Shemp'] }
],
foo: 'bar'
},
handlebars:
'{{#each names}}{{#each name}}{{../bat}}{{../../foo}}{{/each}}{{/each}}',
mustache: '{{#names}}{{#name}}{{bat}}{{foo}}{{/name}}{{/names}}',
eco: '<% for item in @names: %><% for child in item.name: %><%= item.bat %><%= @foo %><% end %><% end %>'
eco:
'<% for item in @names: %><% for child in item.name: %><%= item.bat %><%= @foo %><% end %><% end %>'
};
2 changes: 1 addition & 1 deletion bench/templates/index.js
Expand Up @@ -2,7 +2,7 @@ var fs = require('fs');

var templates = fs.readdirSync(__dirname);
templates.forEach(function(template) {
if (template === 'index.js' || !(/(.*)\.js$/.test(template))) {
if (template === 'index.js' || !/(.*)\.js$/.test(template)) {
return;
}
module.exports[RegExp.$1] = require('./' + RegExp.$1);
Expand Down
5 changes: 4 additions & 1 deletion bench/templates/partial-recursion.js
@@ -1,5 +1,8 @@
module.exports = {
context: { name: '1', kids: [{ name: '1.1', kids: [{name: '1.1.1', kids: []}] }] },
context: {
name: '1',
kids: [{ name: '1.1', kids: [{ name: '1.1.1', kids: [] }] }]
},
partials: {
mustache: { recursion: '{{name}}{{#kids}}{{>recursion}}{{/kids}}' },
handlebars: { recursion: '{{name}}{{#each kids}}{{>recursion}}{{/each}}' }
Expand Down
12 changes: 10 additions & 2 deletions bench/templates/partial.js
@@ -1,8 +1,16 @@
module.exports = {
context: { peeps: [{name: 'Moe', count: 15}, {name: 'Larry', count: 5}, {name: 'Curly', count: 1}] },
context: {
peeps: [
{ name: 'Moe', count: 15 },
{ name: 'Larry', count: 5 },
{ name: 'Curly', count: 1 }
]
},
partials: {
mustache: { variables: 'Hello {{name}}! You have {{count}} new messages.' },
handlebars: { variables: 'Hello {{name}}! You have {{count}} new messages.' }
handlebars: {
variables: 'Hello {{name}}! You have {{count}} new messages.'
}
},

handlebars: '{{#each peeps}}{{>variables}}{{/each}}',
Expand Down

0 comments on commit 3fb331e

Please sign in to comment.