[8.6] Add custom Buildkite pipeline for @kbn/handlebars (#146964) (#147275)

# Backport

This will backport the following commits from `main` to `8.6`:
- [Add custom Buildkite pipeline for @kbn/handlebars
(#146964)](https://github.com/elastic/kibana/pull/146964)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Thomas
Watson","email":"watson@elastic.co"},"sourceCommit":{"committedDate":"2022-12-08T17:28:33Z","message":"Add
custom Buildkite pipeline for @kbn/handlebars (#146964)\n\nCloses
#146963","sha":"39d27bb868ba5e0d544a0fa17afb19abf650c7bf","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","v8.7.0"],"number":146964,"url":"https://github.com/elastic/kibana/pull/146964","mergeCommit":{"message":"Add
custom Buildkite pipeline for @kbn/handlebars (#146964)\n\nCloses
#146963","sha":"39d27bb868ba5e0d544a0fa17afb19abf650c7bf"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146964","number":146964,"mergeCommit":{"message":"Add
custom Buildkite pipeline for @kbn/handlebars (#146964)\n\nCloses
#146963","sha":"39d27bb868ba5e0d544a0fa17afb19abf650c7bf"}}]}]
BACKPORT-->

Co-authored-by: Thomas Watson <watson@elastic.co>
This commit is contained in:
Kibana Machine 2022-12-12 05:30:09 -05:00 committed by GitHub
parent a232b21207
commit f67c20d32f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 323 additions and 235 deletions

View file

@ -0,0 +1,11 @@
steps:
- command: .buildkite/scripts/steps/test/kbn_handlebars.sh
label: 'Check @kbn/handlebars for upstream differences'
agents:
queue: n2-2-spot
depends_on: build
timeout_in_minutes: 5
retry:
automatic:
- exit_status: '*'
limit: 1

View file

@ -54,6 +54,10 @@ const uploadPipeline = (pipelineContent: string | object) => {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/base.yml', false)); pipeline.push(getPipeline('.buildkite/pipelines/pull_request/base.yml', false));
if (await doAnyChangesMatch([/^packages\/kbn-handlebars/])) {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/kbn_handlebars.yml'));
}
if ( if (
(await doAnyChangesMatch([ (await doAnyChangesMatch([
/^packages\/kbn-securitysolution-.*/, /^packages\/kbn-securitysolution-.*/,

View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
source .buildkite/scripts/common/util.sh
echo '--- Checking for @kbn/handlebars test changes'
packages/kbn-handlebars/scripts/check_for_test_changes.sh

View file

@ -1,15 +1,5 @@
1,11c1,21 1c1,6
< global.handlebarsEnv = null; < global.handlebarsEnv = null;
<
< beforeEach(function() {
< global.handlebarsEnv = Handlebars.create();
< });
<
< describe('basic context', function() {
< it('most basic', function() {
< expectTemplate('{{foo}}')
< .withInput({ foo: 'foo' })
< .toCompileTo('foo');
--- ---
> /* > /*
> * This file is forked from the handlebars project (https://github.com/handlebars-lang/handlebars.js), > * This file is forked from the handlebars project (https://github.com/handlebars-lang/handlebars.js),
@ -17,22 +7,24 @@
> * Elasticsearch B.V. licenses this file to you under the MIT License. > * Elasticsearch B.V. licenses this file to you under the MIT License.
> * See `packages/kbn-handlebars/LICENSE` for more information. > * See `packages/kbn-handlebars/LICENSE` for more information.
> */ > */
> 3,5c8,9
< beforeEach(function() {
< global.handlebarsEnv = Handlebars.create();
< });
---
> import Handlebars from '../..'; > import Handlebars from '../..';
> import { expectTemplate } from '../__jest__/test_bench'; > import { expectTemplate } from '../__jest__/test_bench';
> 7,11c11,13
< describe('basic context', function() {
< it('most basic', function() {
< expectTemplate('{{foo}}')
< .withInput({ foo: 'foo' })
< .toCompileTo('foo');
---
> describe('basic context', () => { > describe('basic context', () => {
> it('most basic', () => { > it('most basic', () => {
> expectTemplate('{{foo}}').withInput({ foo: 'foo' }).toCompileTo('foo'); > expectTemplate('{{foo}}').withInput({ foo: 'foo' }).toCompileTo('foo');
> }); 14,33c16,21
>
> it('escaping', () => {
> expectTemplate('\\{{foo}}').withInput({ foo: 'food' }).toCompileTo('{{foo}}');
> expectTemplate('content \\{{foo}}').withInput({ foo: 'food' }).toCompileTo('content {{foo}}');
> expectTemplate('\\\\{{foo}}').withInput({ foo: 'food' }).toCompileTo('\\food');
> expectTemplate('content \\\\{{foo}}').withInput({ foo: 'food' }).toCompileTo('content \\food');
> expectTemplate('\\\\ {{foo}}').withInput({ foo: 'food' }).toCompileTo('\\\\ food');
14,36c24
< it('escaping', function() { < it('escaping', function() {
< expectTemplate('\\{{foo}}') < expectTemplate('\\{{foo}}')
< .withInput({ foo: 'food' }) < .withInput({ foo: 'food' })
@ -53,8 +45,14 @@
< expectTemplate('\\\\ {{foo}}') < expectTemplate('\\\\ {{foo}}')
< .withInput({ foo: 'food' }) < .withInput({ foo: 'food' })
< .toCompileTo('\\\\ food'); < .toCompileTo('\\\\ food');
< }); ---
< > it('escaping', () => {
> expectTemplate('\\{{foo}}').withInput({ foo: 'food' }).toCompileTo('{{foo}}');
> expectTemplate('content \\{{foo}}').withInput({ foo: 'food' }).toCompileTo('content {{foo}}');
> expectTemplate('\\\\{{foo}}').withInput({ foo: 'food' }).toCompileTo('\\food');
> expectTemplate('content \\\\{{foo}}').withInput({ foo: 'food' }).toCompileTo('content \\food');
> expectTemplate('\\\\ {{foo}}').withInput({ foo: 'food' }).toCompileTo('\\\\ food');
36c24
< it('compiling with a basic context', function() { < it('compiling with a basic context', function() {
--- ---
> it('compiling with a basic context', () => { > it('compiling with a basic context', () => {
@ -199,7 +197,7 @@
> it('newlines', () => { > it('newlines', () => {
190d150 190d150
< <
194,223c154,160 194,216c154,159
< it('escaping text', function() { < it('escaping text', function() {
< expectTemplate("Awesome's") < expectTemplate("Awesome's")
< .withMessage( < .withMessage(
@ -223,13 +221,6 @@
< expectTemplate(" ' ' ") < expectTemplate(" ' ' ")
< .withMessage('double quotes never produce invalid javascript') < .withMessage('double quotes never produce invalid javascript')
< .toCompileTo(" ' ' "); < .toCompileTo(" ' ' ");
< });
<
< it('escaping expressions', function() {
< expectTemplate('{{{awesome}}}')
< .withInput({ awesome: "&'\\<>" })
< .withMessage("expressions with 3 handlebars aren't escaped")
< .toCompileTo("&'\\<>");
--- ---
> it('escaping text', () => { > it('escaping text', () => {
> expectTemplate("Awesome's").toCompileTo("Awesome's"); > expectTemplate("Awesome's").toCompileTo("Awesome's");
@ -237,16 +228,21 @@
> expectTemplate('Awesome\\\\ foo').toCompileTo('Awesome\\\\ foo'); > expectTemplate('Awesome\\\\ foo').toCompileTo('Awesome\\\\ foo');
> expectTemplate('Awesome {{foo}}').withInput({ foo: '\\' }).toCompileTo('Awesome \\'); > expectTemplate('Awesome {{foo}}').withInput({ foo: '\\' }).toCompileTo('Awesome \\');
> expectTemplate(" ' ' ").toCompileTo(" ' ' "); > expectTemplate(" ' ' ").toCompileTo(" ' ' ");
> }); 219,223c162,163
225,228c162,165 < it('escaping expressions', function() {
< expectTemplate('{{{awesome}}}')
< .withInput({ awesome: "&'\\<>" })
< .withMessage("expressions with 3 handlebars aren't escaped")
< .toCompileTo("&'\\<>");
---
> it('escaping expressions', () => {
> expectTemplate('{{{awesome}}}').withInput({ awesome: "&'\\<>" }).toCompileTo("&'\\<>");
225,228c165
< expectTemplate('{{&awesome}}') < expectTemplate('{{&awesome}}')
< .withInput({ awesome: "&'\\<>" }) < .withInput({ awesome: "&'\\<>" })
< .withMessage("expressions with {{& handlebars aren't escaped") < .withMessage("expressions with {{& handlebars aren't escaped")
< .toCompileTo("&'\\<>"); < .toCompileTo("&'\\<>");
--- ---
> it('escaping expressions', () => {
> expectTemplate('{{{awesome}}}').withInput({ awesome: "&'\\<>" }).toCompileTo("&'\\<>");
>
> expectTemplate('{{&awesome}}').withInput({ awesome: "&'\\<>" }).toCompileTo("&'\\<>"); > expectTemplate('{{&awesome}}').withInput({ awesome: "&'\\<>" }).toCompileTo("&'\\<>");
232d168 232d168
< .withMessage('by default expressions should be escaped') < .withMessage('by default expressions should be escaped')

View file

@ -420,7 +420,7 @@
< equals(run, true); < equals(run, true);
--- ---
> expect(run).toEqual(true); > expect(run).toEqual(true);
406,408c314,321 406,408c314,317
< describe('registration', function() { < describe('registration', function() {
< it('unregisters', function() { < it('unregisters', function() {
< handlebarsEnv.decorators = {}; < handlebarsEnv.decorators = {};
@ -429,13 +429,13 @@
> beforeEach(() => { > beforeEach(() => {
> global.kbnHandlebarsEnv = Handlebars.create(); > global.kbnHandlebarsEnv = Handlebars.create();
> }); > });
> 410c319,323
< handlebarsEnv.registerDecorator('foo', function() {
---
> it('unregisters', () => { > it('unregisters', () => {
> // @ts-expect-error: Cannot assign to 'decorators' because it is a read-only property. > // @ts-expect-error: Cannot assign to 'decorators' because it is a read-only property.
> kbnHandlebarsEnv!.decorators = {}; > kbnHandlebarsEnv!.decorators = {};
410c323 >
< handlebarsEnv.registerDecorator('foo', function() {
---
> kbnHandlebarsEnv!.registerDecorator('foo', function () { > kbnHandlebarsEnv!.registerDecorator('foo', function () {
414,416c327,329 414,416c327,329
< equals(!!handlebarsEnv.decorators.foo, true); < equals(!!handlebarsEnv.decorators.foo, true);
@ -445,18 +445,18 @@
> expect(!!kbnHandlebarsEnv!.decorators.foo).toEqual(true); > expect(!!kbnHandlebarsEnv!.decorators.foo).toEqual(true);
> kbnHandlebarsEnv!.unregisterDecorator('foo'); > kbnHandlebarsEnv!.unregisterDecorator('foo');
> expect(kbnHandlebarsEnv!.decorators.foo).toBeUndefined(); > expect(kbnHandlebarsEnv!.decorators.foo).toBeUndefined();
419,424c332,339 419,420c332,334
< it('allows multiple globals', function() { < it('allows multiple globals', function() {
< handlebarsEnv.decorators = {}; < handlebarsEnv.decorators = {};
<
< handlebarsEnv.registerDecorator({
< foo: function() {},
< bar: function() {}
--- ---
> it('allows multiple globals', () => { > it('allows multiple globals', () => {
> // @ts-expect-error: Cannot assign to 'decorators' because it is a read-only property. > // @ts-expect-error: Cannot assign to 'decorators' because it is a read-only property.
> kbnHandlebarsEnv!.decorators = {}; > kbnHandlebarsEnv!.decorators = {};
> 422,424c336,339
< handlebarsEnv.registerDecorator({
< foo: function() {},
< bar: function() {}
---
> // @ts-expect-error: Expected 2 arguments, but got 1. > // @ts-expect-error: Expected 2 arguments, but got 1.
> kbnHandlebarsEnv!.registerDecorator({ > kbnHandlebarsEnv!.registerDecorator({
> foo() {}, > foo() {},

View file

@ -341,7 +341,7 @@
> // TODO: This test has been added to the `4.x` branch of the handlebars.js repo along with a code-fix, > // TODO: This test has been added to the `4.x` branch of the handlebars.js repo along with a code-fix,
> // but a new version of the handlebars package containing this fix has not yet been published to npm. > // but a new version of the handlebars package containing this fix has not yet been published to npm.
> // > //
> // Before enabling this code, a new version of handlebars needs to be released and the corrosponding > // Before enabling this code, a new version of handlebars needs to be released and the corresponding
> // updates needs to be applied to this implementation. > // updates needs to be applied to this implementation.
> // > //
> // See: https://github.com/handlebars-lang/handlebars.js/commit/30dbf0478109ded8f12bb29832135d480c17e367 > // See: https://github.com/handlebars-lang/handlebars.js/commit/30dbf0478109ded8f12bb29832135d480c17e367
@ -703,20 +703,20 @@
--- ---
> expect('03').toEqual(levelArg); > expect('03').toEqual(levelArg);
> expect('whee').toEqual(logArg); > expect('whee').toEqual(logArg);
609,616c511,521 609,610c511,513
< it('should output to info', function() { < it('should output to info', function() {
< var called; < var called;
< ---
> it('should output to info', function () {
> let calls = 0;
> const callsExpected = process.env.AST || process.env.EVAL ? 1 : 2;
612,616c515,521
< console.info = function(info) { < console.info = function(info) {
< equals('whee', info); < equals('whee', info);
< called = true; < called = true;
< console.info = $info; < console.info = $info;
< console.log = $log; < console.log = $log;
--- ---
> it('should output to info', function () {
> let calls = 0;
> const callsExpected = process.env.AST || process.env.EVAL ? 1 : 2;
>
> console.info = function (info) { > console.info = function (info) {
> expect('whee').toEqual(info); > expect('whee').toEqual(info);
> calls++; > calls++;
@ -746,19 +746,19 @@
--- ---
> expectTemplate('{{log blah}}').withInput({ blah: 'whee' }).toCompileTo(''); > expectTemplate('{{log blah}}').withInput({ blah: 'whee' }).toCompileTo('');
> expect(calls).toEqual(callsExpected); > expect(calls).toEqual(callsExpected);
631,637c536,543 631,632c536,538
< it('should log at data level', function() { < it('should log at data level', function() {
< var called; < var called;
< ---
> it('should log at data level', function () {
> let calls = 0;
> const callsExpected = process.env.AST || process.env.EVAL ? 1 : 2;
634,637c540,543
< console.error = function(log) { < console.error = function(log) {
< equals('whee', log); < equals('whee', log);
< called = true; < called = true;
< console.error = $error; < console.error = $error;
--- ---
> it('should log at data level', function () {
> let calls = 0;
> const callsExpected = process.env.AST || process.env.EVAL ? 1 : 2;
>
> console.error = function (log) { > console.error = function (log) {
> expect('whee').toEqual(log); > expect('whee').toEqual(log);
> calls++; > calls++;

View file

@ -1,15 +1,24 @@
1,92c1,24 1,4c1,6
< describe('compiler', function() { < describe('compiler', function() {
< if (!Handlebars.compile) { < if (!Handlebars.compile) {
< return; < return;
< } < }
< ---
> /*
> * This file is forked from the handlebars project (https://github.com/handlebars-lang/handlebars.js),
> * and may include modifications made by Elasticsearch B.V.
> * Elasticsearch B.V. licenses this file to you under the MIT License.
> * See `packages/kbn-handlebars/LICENSE` for more information.
> */
6,10c8
< describe('#equals', function() { < describe('#equals', function() {
< function compile(string) { < function compile(string) {
< var ast = Handlebars.parse(string); < var ast = Handlebars.parse(string);
< return new Handlebars.Compiler().compile(ast, {}); < return new Handlebars.Compiler().compile(ast, {});
< } < }
< ---
> import Handlebars from '../..';
12,60c10,13
< it('should treat as equal', function() { < it('should treat as equal', function() {
< equal(compile('foo').equals(compile('foo')), true); < equal(compile('foo').equals(compile('foo')), true);
< equal(compile('{{foo}}').equals(compile('{{foo}}')), true); < equal(compile('{{foo}}').equals(compile('{{foo}}')), true);
@ -59,7 +68,12 @@
< ); < );
< }); < });
< }); < });
< ---
> describe('compiler', () => {
> const compileFns = ['compile', 'compileAST'];
> if (process.env.AST) compileFns.splice(0, 1);
> else if (process.env.EVAL) compileFns.splice(1, 1);
62,78c15,17
< describe('#compile', function() { < describe('#compile', function() {
< it('should fail with invalid input', function() { < it('should fail with invalid input', function() {
< shouldThrow( < shouldThrow(
@ -77,7 +91,11 @@
< 'You must pass a string or Handlebars AST to Handlebars.compile. You passed [object Object]' < 'You must pass a string or Handlebars AST to Handlebars.compile. You passed [object Object]'
< ); < );
< }); < });
< ---
> compileFns.forEach((compileName) => {
> // @ts-expect-error
> const compile = Handlebars[compileName];
80,92c19,24
< it('should include the location in the error (row and column)', function() { < it('should include the location in the error (row and column)', function() {
< try { < try {
< Handlebars.compile(' \n {{#if}}\n{{/def}}')(); < Handlebars.compile(' \n {{#if}}\n{{/def}}')();
@ -92,24 +110,6 @@
< "if doesn't match def - 2:5", < "if doesn't match def - 2:5",
< 'Checking error message' < 'Checking error message'
--- ---
> /*
> * This file is forked from the handlebars project (https://github.com/handlebars-lang/handlebars.js),
> * and may include modifications made by Elasticsearch B.V.
> * Elasticsearch B.V. licenses this file to you under the MIT License.
> * See `packages/kbn-handlebars/LICENSE` for more information.
> */
>
> import Handlebars from '../..';
>
> describe('compiler', () => {
> const compileFns = ['compile', 'compileAST'];
> if (process.env.AST) compileFns.splice(0, 1);
> else if (process.env.EVAL) compileFns.splice(1, 1);
>
> compileFns.forEach((compileName) => {
> // @ts-expect-error
> const compile = Handlebars[compileName];
>
> describe(`#${compileName}`, () => { > describe(`#${compileName}`, () => {
> it('should fail with invalid input', () => { > it('should fail with invalid input', () => {
> expect(function () { > expect(function () {
@ -160,29 +160,10 @@
< }); < });
--- ---
> }); > });
131,152c34,48 131,133c34,48
< it('can pass through an empty string', function() { < it('can pass through an empty string', function() {
< equal(Handlebars.compile('')(), ''); < equal(Handlebars.compile('')(), '');
< }); < });
<
< it('should not modify the options.data property(GH-1327)', function() {
< var options = { data: [{ a: 'foo' }, { a: 'bar' }] };
< Handlebars.compile('{{#each data}}{{@index}}:{{a}} {{/each}}', options)();
< equal(
< JSON.stringify(options, 0, 2),
< JSON.stringify({ data: [{ a: 'foo' }, { a: 'bar' }] }, 0, 2)
< );
< });
<
< it('should not modify the options.knownHelpers property(GH-1327)', function() {
< var options = { knownHelpers: {} };
< Handlebars.compile('{{#each data}}{{@index}}:{{a}} {{/each}}', options)();
< equal(
< JSON.stringify(options, 0, 2),
< JSON.stringify({ knownHelpers: {} }, 0, 2)
< );
< });
< });
--- ---
> it('should include the location in the error (row and column)', () => { > it('should include the location in the error (row and column)', () => {
> try { > try {
@ -199,7 +180,44 @@
> expect(err.lineNumber).toEqual(2); > expect(err.lineNumber).toEqual(2);
> } > }
> }); > });
154,170c50,57 135,142c50,57
< it('should not modify the options.data property(GH-1327)', function() {
< var options = { data: [{ a: 'foo' }, { a: 'bar' }] };
< Handlebars.compile('{{#each data}}{{@index}}:{{a}} {{/each}}', options)();
< equal(
< JSON.stringify(options, 0, 2),
< JSON.stringify({ data: [{ a: 'foo' }, { a: 'bar' }] }, 0, 2)
< );
< });
---
> it('should include the location as enumerable property', () => {
> try {
> compile(' \n {{#if}}\n{{/def}}')({});
> expect(true).toEqual(false);
> } catch (err) {
> expect(Object.prototype.propertyIsEnumerable.call(err, 'column')).toEqual(true);
> }
> });
144,152c59,66
< it('should not modify the options.knownHelpers property(GH-1327)', function() {
< var options = { knownHelpers: {} };
< Handlebars.compile('{{#each data}}{{@index}}:{{a}} {{/each}}', options)();
< equal(
< JSON.stringify(options, 0, 2),
< JSON.stringify({ knownHelpers: {} }, 0, 2)
< );
< });
< });
---
> it('can utilize AST instance', () => {
> expect(
> compile({
> type: 'Program',
> body: [{ type: 'ContentStatement', value: 'Hello' }],
> })({})
> ).toEqual('Hello');
> });
154,170c68,70
< describe('#precompile', function() { < describe('#precompile', function() {
< it('should fail with invalid input', function() { < it('should fail with invalid input', function() {
< shouldThrow( < shouldThrow(
@ -218,24 +236,15 @@
< ); < );
< }); < });
--- ---
> it('should include the location as enumerable property', () => { > it('can pass through an empty string', () => {
> try { > expect(compile('')({})).toEqual('');
> compile(' \n {{#if}}\n{{/def}}')({});
> expect(true).toEqual(false);
> } catch (err) {
> expect(Object.prototype.propertyIsEnumerable.call(err, 'column')).toEqual(true);
> }
> }); > });
172,175c59,61 172,182c72,78
< it('can utilize AST instance', function() { < it('can utilize AST instance', function() {
< equal( < equal(
< /return "Hello"/.test( < /return "Hello"/.test(
< Handlebars.precompile({ < Handlebars.precompile({
--- < type: 'Program',
> it('can utilize AST instance', () => {
> expect(
> compile({
177,182c63,78
< body: [{ type: 'ContentStatement', value: 'Hello' }] < body: [{ type: 'ContentStatement', value: 'Hello' }]
< }) < })
< ), < ),
@ -243,15 +252,6 @@
< ); < );
< }); < });
--- ---
> body: [{ type: 'ContentStatement', value: 'Hello' }],
> })({})
> ).toEqual('Hello');
> });
>
> it('can pass through an empty string', () => {
> expect(compile('')({})).toEqual('');
> });
>
> it('should not modify the options.data property(GH-1327)', () => { > it('should not modify the options.data property(GH-1327)', () => {
> const options = { data: [{ a: 'foo' }, { a: 'bar' }] }; > const options = { data: [{ a: 'foo' }, { a: 'bar' }] };
> compile('{{#each data}}{{@index}}:{{a}} {{/each}}', options)({}); > compile('{{#each data}}{{@index}}:{{a}} {{/each}}', options)({});

View file

@ -306,21 +306,22 @@
> helper: () => 'winning', > helper: () => 'winning',
293a271 293a271
> // @ts-expect-error > // @ts-expect-error
295,298c273,275 295,299d272
< var helpers = { < var helpers = {
< './helper': function() { < './helper': function() {
< return 'fail'; < return 'fail';
< } < }
--- < };
> 301,304c274,276
> const helpers = {
> './helper': () => 'fail',
301,309c278,279
< expectTemplate('{{./helper 1}}') < expectTemplate('{{./helper 1}}')
< .withInput(hash) < .withInput(hash)
< .withHelpers(helpers) < .withHelpers(helpers)
< .toCompileTo('winning'); < .toCompileTo('winning');
< ---
> const helpers = {
> './helper': () => 'fail',
> };
306,309c278,279
< expectTemplate('{{hash/helper 1}}') < expectTemplate('{{hash/helper 1}}')
< .withInput(hash) < .withInput(hash)
< .withHelpers(helpers) < .withHelpers(helpers)
@ -431,19 +432,19 @@
> expect(kbnHandlebarsEnv!.helpers.foo).toBeDefined(); > expect(kbnHandlebarsEnv!.helpers.foo).toBeDefined();
> kbnHandlebarsEnv!.unregisterHelper('foo'); > kbnHandlebarsEnv!.unregisterHelper('foo');
> expect(kbnHandlebarsEnv!.helpers.foo).toBeUndefined(); > expect(kbnHandlebarsEnv!.helpers.foo).toBeUndefined();
398,404c362,368 398,400c362,364
< it('allows multiple globals', function() { < it('allows multiple globals', function() {
< var helpers = handlebarsEnv.helpers; < var helpers = handlebarsEnv.helpers;
< handlebarsEnv.helpers = {}; < handlebarsEnv.helpers = {};
<
< handlebarsEnv.registerHelper({
< if: helpers['if'],
< world: function() {
--- ---
> it('allows multiple globals', () => { > it('allows multiple globals', () => {
> const ifHelper = kbnHandlebarsEnv!.helpers.if; > const ifHelper = kbnHandlebarsEnv!.helpers.if;
> deleteAllKeys(kbnHandlebarsEnv!.helpers); > deleteAllKeys(kbnHandlebarsEnv!.helpers);
> 402,404c366,368
< handlebarsEnv.registerHelper({
< if: helpers['if'],
< world: function() {
---
> kbnHandlebarsEnv!.registerHelper({ > kbnHandlebarsEnv!.registerHelper({
> if: ifHelper, > if: ifHelper,
> world() { > world() {

View file

@ -1,14 +1,10 @@
1,10c1,15 1,6c1,6
< describe('security issues', function() { < describe('security issues', function() {
< describe('GH-1495: Prevent Remote Code Execution via constructor', function() { < describe('GH-1495: Prevent Remote Code Execution via constructor', function() {
< it('should not allow constructors to be accessed', function() { < it('should not allow constructors to be accessed', function() {
< expectTemplate('{{lookup (lookup this "constructor") "name"}}') < expectTemplate('{{lookup (lookup this "constructor") "name"}}')
< .withInput({}) < .withInput({})
< .toCompileTo(''); < .toCompileTo('');
<
< expectTemplate('{{constructor.name}}')
< .withInput({})
< .toCompileTo('');
--- ---
> /* > /*
> * This file is forked from the handlebars project (https://github.com/handlebars-lang/handlebars.js), > * This file is forked from the handlebars project (https://github.com/handlebars-lang/handlebars.js),
@ -16,7 +12,11 @@
> * Elasticsearch B.V. licenses this file to you under the MIT License. > * Elasticsearch B.V. licenses this file to you under the MIT License.
> * See `packages/kbn-handlebars/LICENSE` for more information. > * See `packages/kbn-handlebars/LICENSE` for more information.
> */ > */
> 8,10c8,15
< expectTemplate('{{constructor.name}}')
< .withInput({})
< .toCompileTo('');
---
> import Handlebars from '../..'; > import Handlebars from '../..';
> import { expectTemplate } from '../__jest__/test_bench'; > import { expectTemplate } from '../__jest__/test_bench';
> >
@ -150,7 +150,7 @@
< '{{lookup this "__proto__"}}' < '{{lookup this "__proto__"}}'
--- ---
> '{{lookup this "__proto__"}}', > '{{lookup this "__proto__"}}',
144,257c111,114 144,382c111,114
< templates.forEach(function(template) { < templates.forEach(function(template) {
< describe('access should be denied to ' + template, function() { < describe('access should be denied to ' + template, function() {
< it('by default', function() { < it('by default', function() {
@ -265,12 +265,7 @@
< .toCompileTo(''); < .toCompileTo('');
< <
< expect(spy.callCount).to.equal(0); < expect(spy.callCount).to.equal(0);
--- < });
> templates.forEach((template) => {
> describe('access should be denied to ' + template, () => {
> it('by default', () => {
> expectTemplate(template).withInput({}).toCompileTo('');
259,399d115
< <
< it('can be turned off, if turned on by default', function() { < it('can be turned off, if turned on by default', function() {
< expectTemplate('{{aMethod}}') < expectTemplate('{{aMethod}}')
@ -395,8 +390,12 @@
< sinon.replace(handlebarsEnv, 'template', function(templateSpec) { < sinon.replace(handlebarsEnv, 'template', function(templateSpec) {
< templateSpec.main = wrapToAdjustContainer(templateSpec.main); < templateSpec.main = wrapToAdjustContainer(templateSpec.main);
< return oldTemplateMethod.call(this, templateSpec); < return oldTemplateMethod.call(this, templateSpec);
< }); ---
< }); > templates.forEach((template) => {
> describe('access should be denied to ' + template, () => {
> it('by default', () => {
> expectTemplate(template).withInput({}).toCompileTo('');
385,400d116
< <
< afterEach(function() { < afterEach(function() {
< sinon.restore(); < sinon.restore();
@ -412,6 +411,7 @@
< expectTemplate('{{anArray.length}}') < expectTemplate('{{anArray.length}}')
< .withInput({ anArray: ['a', 'b', 'c'] }) < .withInput({ anArray: ['a', 'b', 'c'] })
< .toCompileTo('3'); < .toCompileTo('3');
< });
404,409c120,122 404,409c120,122
< describe('escapes template variables', function() { < describe('escapes template variables', function() {
< it('in compat mode', function() { < it('in compat mode', function() {

View file

@ -1,9 +1,5 @@
1,5c1,12 1c1,6
< var Exception = Handlebars.Exception; < var Exception = Handlebars.Exception;
<
< describe('strict', function() {
< describe('strict mode', function() {
< it('should error on missing property lookup', function() {
--- ---
> /* > /*
> * This file is forked from the handlebars project (https://github.com/handlebars-lang/handlebars.js), > * This file is forked from the handlebars project (https://github.com/handlebars-lang/handlebars.js),
@ -11,7 +7,11 @@
> * Elasticsearch B.V. licenses this file to you under the MIT License. > * Elasticsearch B.V. licenses this file to you under the MIT License.
> * See `packages/kbn-handlebars/LICENSE` for more information. > * See `packages/kbn-handlebars/LICENSE` for more information.
> */ > */
> 3,5c8,12
< describe('strict', function() {
< describe('strict mode', function() {
< it('should error on missing property lookup', function() {
---
> import { expectTemplate } from '../__jest__/test_bench'; > import { expectTemplate } from '../__jest__/test_bench';
> >
> describe('strict', () => { > describe('strict', () => {

View file

@ -214,7 +214,7 @@
< t: function(defaultString) { < t: function(defaultString) {
--- ---
> t(defaultString) { > t(defaultString) {
186,212d181 186,242d181
< } < }
< }) < })
< .toCompileTo('<input aria-label="Name" placeholder="Example User" />'); < .toCompileTo('<input aria-label="Name" placeholder="Example User" />');
@ -242,7 +242,7 @@
< 'string params for outer helper processed correctly' < 'string params for outer helper processed correctly'
< ); < );
< return a + b; < return a + b;
214,231d182 < },
< <
< blorg: function(a, options) { < blorg: function(a, options) {
< equals( < equals(
@ -261,7 +261,7 @@
< .withInput({ < .withInput({
< foo: {}, < foo: {},
< yeah: {} < yeah: {}
233,248c184 < })
< .toCompileTo('fooyeah'); < .toCompileTo('fooyeah');
< }); < });
< <
@ -272,11 +272,11 @@
< blog: function(options) { < blog: function(options) {
< equals(options.hashTypes.fun, 'SubExpression'); < equals(options.hashTypes.fun, 'SubExpression');
< return 'val is ' + options.hash.fun; < return 'val is ' + options.hash.fun;
< }, 244,246d182
< bork: function() { < bork: function() {
< return 'BORK'; < return 'BORK';
< } < }
< }) 248c184
< .toCompileTo('val is BORK'); < .toCompileTo('val is BORK');
--- ---
> .toCompileTo('<input aria-label="Name" placeholder="Example User" />'); > .toCompileTo('<input aria-label="Name" placeholder="Example User" />');

View file

@ -1,4 +1,4 @@
1,86c1,21 1,55c1,6
< describe('utils', function() { < describe('utils', function() {
< describe('#SafeString', function() { < describe('#SafeString', function() {
< it('constructing a safestring from a string and checking its type', function() { < it('constructing a safestring from a string and checking its type', function() {
@ -54,7 +54,14 @@
< equals(Handlebars.Utils.escapeExpression([]), [].toString()); < equals(Handlebars.Utils.escapeExpression([]), [].toString());
< }); < });
< }); < });
< ---
> /*
> * This file is forked from the handlebars project (https://github.com/handlebars-lang/handlebars.js),
> * and may include modifications made by Elasticsearch B.V.
> * Elasticsearch B.V. licenses this file to you under the MIT License.
> * See `packages/kbn-handlebars/LICENSE` for more information.
> */
57,64c8,9
< describe('#isEmpty', function() { < describe('#isEmpty', function() {
< it('should not be empty', function() { < it('should not be empty', function() {
< equals(Handlebars.Utils.isEmpty(undefined), true); < equals(Handlebars.Utils.isEmpty(undefined), true);
@ -63,13 +70,23 @@
< equals(Handlebars.Utils.isEmpty(''), true); < equals(Handlebars.Utils.isEmpty(''), true);
< equals(Handlebars.Utils.isEmpty([]), true); < equals(Handlebars.Utils.isEmpty([]), true);
< }); < });
< ---
> import Handlebars from '../..';
> import { expectTemplate } from '../__jest__/test_bench';
66,70c11,16
< it('should be empty', function() { < it('should be empty', function() {
< equals(Handlebars.Utils.isEmpty(0), false); < equals(Handlebars.Utils.isEmpty(0), false);
< equals(Handlebars.Utils.isEmpty([1]), false); < equals(Handlebars.Utils.isEmpty([1]), false);
< equals(Handlebars.Utils.isEmpty('foo'), false); < equals(Handlebars.Utils.isEmpty('foo'), false);
< equals(Handlebars.Utils.isEmpty({ bar: 1 }), false); < equals(Handlebars.Utils.isEmpty({ bar: 1 }), false);
< }); ---
> describe('utils', function () {
> describe('#SafeString', function () {
> it('constructing a safestring from a string and checking its type', function () {
> const safe = new Handlebars.SafeString('testing 1, 2, 3');
> expect(safe).toBeInstanceOf(Handlebars.SafeString);
> expect(safe.toString()).toEqual('testing 1, 2, 3');
72,83d17
< }); < });
< <
< describe('#extend', function() { < describe('#extend', function() {
@ -82,28 +99,10 @@
< var b = { b: 2 }; < var b = { b: 2 };
< <
< Handlebars.Utils.extend(b, new A()); < Handlebars.Utils.extend(b, new A());
< 85,86c19,21
< equals(b.a, 1); < equals(b.a, 1);
< equals(b.b, 2); < equals(b.b, 2);
--- ---
> /*
> * This file is forked from the handlebars project (https://github.com/handlebars-lang/handlebars.js),
> * and may include modifications made by Elasticsearch B.V.
> * Elasticsearch B.V. licenses this file to you under the MIT License.
> * See `packages/kbn-handlebars/LICENSE` for more information.
> */
>
> import Handlebars from '../..';
> import { expectTemplate } from '../__jest__/test_bench';
>
> describe('utils', function () {
> describe('#SafeString', function () {
> it('constructing a safestring from a string and checking its type', function () {
> const safe = new Handlebars.SafeString('testing 1, 2, 3');
> expect(safe).toBeInstanceOf(Handlebars.SafeString);
> expect(safe.toString()).toEqual('testing 1, 2, 3');
> });
>
> it('it should not escape SafeString properties', function () { > it('it should not escape SafeString properties', function () {
> const name = new Handlebars.SafeString('<em>Sean O&#x27;Malley</em>'); > const name = new Handlebars.SafeString('<em>Sean O&#x27;Malley</em>');
> expectTemplate('{{name}}').withInput({ name }).toCompileTo('<em>Sean O&#x27;Malley</em>'); > expectTemplate('{{name}}').withInput({ name }).toCompileTo('<em>Sean O&#x27;Malley</em>');

View file

@ -1,4 +1,4 @@
1,24c1,17 1,19c1,6
< describe('whitespace control', function() { < describe('whitespace control', function() {
< it('should strip whitespace around mustache calls', function() { < it('should strip whitespace around mustache calls', function() {
< var hash = { foo: 'bar<' }; < var hash = { foo: 'bar<' };
@ -18,11 +18,6 @@
< expectTemplate(' {{~&foo~}} ') < expectTemplate(' {{~&foo~}} ')
< .withInput(hash) < .withInput(hash)
< .toCompileTo('bar<'); < .toCompileTo('bar<');
<
< expectTemplate(' {{~{foo}~}} ')
< .withInput(hash)
< .toCompileTo('bar<');
<
--- ---
> /* > /*
> * This file is forked from the handlebars project (https://github.com/handlebars-lang/handlebars.js), > * This file is forked from the handlebars project (https://github.com/handlebars-lang/handlebars.js),
@ -30,9 +25,13 @@
> * Elasticsearch B.V. licenses this file to you under the MIT License. > * Elasticsearch B.V. licenses this file to you under the MIT License.
> * See `packages/kbn-handlebars/LICENSE` for more information. > * See `packages/kbn-handlebars/LICENSE` for more information.
> */ > */
> 21,23c8
< expectTemplate(' {{~{foo}~}} ')
< .withInput(hash)
< .toCompileTo('bar<');
---
> import { expectTemplate } from '../__jest__/test_bench'; > import { expectTemplate } from '../__jest__/test_bench';
> 24a10,17
> describe('whitespace control', () => { > describe('whitespace control', () => {
> it('should strip whitespace around mustache calls', () => { > it('should strip whitespace around mustache calls', () => {
> const hash = { foo: 'bar<' }; > const hash = { foo: 'bar<' };
@ -41,7 +40,7 @@
> expectTemplate(' {{foo~}} ').withInput(hash).toCompileTo(' bar&lt;'); > expectTemplate(' {{foo~}} ').withInput(hash).toCompileTo(' bar&lt;');
> expectTemplate(' {{~&foo~}} ').withInput(hash).toCompileTo('bar<'); > expectTemplate(' {{~&foo~}} ').withInput(hash).toCompileTo('bar<');
> expectTemplate(' {{~{foo}~}} ').withInput(hash).toCompileTo('bar<'); > expectTemplate(' {{~{foo}~}} ').withInput(hash).toCompileTo('bar<');
28,46c21,28 28,42c21,23
< describe('blocks', function() { < describe('blocks', function() {
< it('should strip whitespace around simple block calls', function() { < it('should strip whitespace around simple block calls', function() {
< var hash = { foo: 'bar<' }; < var hash = { foo: 'bar<' };
@ -57,15 +56,15 @@
< expectTemplate(' {{~#if foo}} bar {{~/if}} ') < expectTemplate(' {{~#if foo}} bar {{~/if}} ')
< .withInput(hash) < .withInput(hash)
< .toCompileTo(' bar '); < .toCompileTo(' bar ');
<
< expectTemplate(' {{#if foo}} bar {{/if}} ')
< .withInput(hash)
< .toCompileTo(' bar ');
--- ---
> describe('blocks', () => { > describe('blocks', () => {
> it('should strip whitespace around simple block calls', () => { > it('should strip whitespace around simple block calls', () => {
> const hash = { foo: 'bar<' }; > const hash = { foo: 'bar<' };
> 44,46c25,28
< expectTemplate(' {{#if foo}} bar {{/if}} ')
< .withInput(hash)
< .toCompileTo(' bar ');
---
> expectTemplate(' {{~#if foo~}} bar {{~/if~}} ').withInput(hash).toCompileTo('bar'); > expectTemplate(' {{~#if foo~}} bar {{~/if~}} ').withInput(hash).toCompileTo('bar');
> expectTemplate(' {{#if foo~}} bar {{/if~}} ').withInput(hash).toCompileTo(' bar '); > expectTemplate(' {{#if foo~}} bar {{/if~}} ').withInput(hash).toCompileTo(' bar ');
> expectTemplate(' {{~#if foo}} bar {{~/if}} ').withInput(hash).toCompileTo(' bar '); > expectTemplate(' {{~#if foo}} bar {{~/if}} ').withInput(hash).toCompileTo(' bar ');
@ -87,7 +86,7 @@
< ).toCompileTo('bar'); < ).toCompileTo('bar');
--- ---
> expectTemplate(' \n\n{{~^if foo~}} \n\nbar \n\n{{~/if~}}\n\n ').toCompileTo('bar'); > expectTemplate(' \n\n{{~^if foo~}} \n\nbar \n\n{{~/if~}}\n\n ').toCompileTo('bar');
71,80c47,48 71,88c47,48
< it('should strip whitespace around complex block calls', function() { < it('should strip whitespace around complex block calls', function() {
< var hash = { foo: 'bar<' }; < var hash = { foo: 'bar<' };
< <
@ -98,34 +97,34 @@
< expectTemplate('{{#if foo~}} bar {{^~}} baz {{/if}}') < expectTemplate('{{#if foo~}} bar {{^~}} baz {{/if}}')
< .withInput(hash) < .withInput(hash)
< .toCompileTo('bar '); < .toCompileTo('bar ');
--- <
> it('should strip whitespace around complex block calls', () => {
> const hash = { foo: 'bar<' };
82,84c50,54
< expectTemplate('{{#if foo}} bar {{~^~}} baz {{~/if}}') < expectTemplate('{{#if foo}} bar {{~^~}} baz {{~/if}}')
< .withInput(hash) < .withInput(hash)
< .toCompileTo(' bar'); < .toCompileTo(' bar');
<
< expectTemplate('{{#if foo}} bar {{^~}} baz {{/if}}')
< .withInput(hash)
< .toCompileTo(' bar ');
---
> it('should strip whitespace around complex block calls', () => {
> const hash = { foo: 'bar<' };
90,92c50,54
< expectTemplate('{{#if foo~}} bar {{~else~}} baz {{~/if}}')
< .withInput(hash)
< .toCompileTo('bar');
--- ---
> expectTemplate('{{#if foo~}} bar {{~^~}} baz {{~/if}}').withInput(hash).toCompileTo('bar'); > expectTemplate('{{#if foo~}} bar {{~^~}} baz {{~/if}}').withInput(hash).toCompileTo('bar');
> expectTemplate('{{#if foo~}} bar {{^~}} baz {{/if}}').withInput(hash).toCompileTo('bar '); > expectTemplate('{{#if foo~}} bar {{^~}} baz {{/if}}').withInput(hash).toCompileTo('bar ');
> expectTemplate('{{#if foo}} bar {{~^~}} baz {{~/if}}').withInput(hash).toCompileTo(' bar'); > expectTemplate('{{#if foo}} bar {{~^~}} baz {{~/if}}').withInput(hash).toCompileTo(' bar');
> expectTemplate('{{#if foo}} bar {{^~}} baz {{/if}}').withInput(hash).toCompileTo(' bar '); > expectTemplate('{{#if foo}} bar {{^~}} baz {{/if}}').withInput(hash).toCompileTo(' bar ');
> expectTemplate('{{#if foo~}} bar {{~else~}} baz {{~/if}}').withInput(hash).toCompileTo('bar'); > expectTemplate('{{#if foo~}} bar {{~else~}} baz {{~/if}}').withInput(hash).toCompileTo('bar');
86,90c56 94,96c56
< expectTemplate('{{#if foo}} bar {{^~}} baz {{/if}}')
< .withInput(hash)
< .toCompileTo(' bar ');
<
< expectTemplate('{{#if foo~}} bar {{~else~}} baz {{~/if}}')
---
> expectTemplate('\n\n{{~#if foo~}} \n\nbar \n\n{{~^~}} \n\nbaz \n\n{{~/if~}}\n\n')
94,102c60
< expectTemplate( < expectTemplate(
< '\n\n{{~#if foo~}} \n\nbar \n\n{{~^~}} \n\nbaz \n\n{{~/if~}}\n\n' < '\n\n{{~#if foo~}} \n\nbar \n\n{{~^~}} \n\nbaz \n\n{{~/if~}}\n\n'
< ) < )
< .withInput(hash) ---
< .toCompileTo('bar'); > expectTemplate('\n\n{{~#if foo~}} \n\nbar \n\n{{~^~}} \n\nbaz \n\n{{~/if~}}\n\n')
< 100,102c60
< expectTemplate( < expectTemplate(
< '\n\n{{~#if foo~}} \n\n{{{foo}}} \n\n{{~^~}} \n\nbaz \n\n{{~/if~}}\n\n' < '\n\n{{~#if foo~}} \n\n{{{foo}}} \n\n{{~^~}} \n\nbaz \n\n{{~/if~}}\n\n'
< ) < )

View file

@ -1,10 +1,29 @@
#!/usr/bin/env bash
set -e set -e
rm -fr .tmp TMP=.tmp-handlebars
mkdir .tmp
# Try to detect Windows environment (I've not tested this!)
if [[ "$OSTYPE" == "msys" ]]; then
# Windows environment
DEVNULL=NUL
else
# Everything else (including Cygwin on Windows)
DEVNULL=/dev/null
fi
function cleanup {
rm -fr $TMP
}
trap cleanup EXIT
rm -fr $TMP
mkdir $TMP
echo "Cloning handlebars repo..." echo "Cloning handlebars repo..."
git clone -q --depth 1 https://github.com/handlebars-lang/handlebars.js.git -b 4.x .tmp/handlebars git clone -q --depth 1 https://github.com/handlebars-lang/handlebars.js.git -b 4.x $TMP/handlebars
files=(packages/kbn-handlebars/src/upstream/index.*.test.ts) files=(packages/kbn-handlebars/src/upstream/index.*.test.ts)
@ -16,18 +35,54 @@ do
echo "Checking for changes to spec/$file.js..." echo "Checking for changes to spec/$file.js..."
set +e set +e
diff .tmp/handlebars/spec/$file.js packages/kbn-handlebars/src/upstream/index.$file.test.ts > .tmp/$file.patch diff -d --strip-trailing-cr $TMP/handlebars/spec/$file.js packages/kbn-handlebars/src/upstream/index.$file.test.ts > $TMP/$file.patch
error=$? error=$?
set -e set -e
if [ $error -gt 1 ] if [ $error -gt 1 ]
then then
echo "Error executing diff!" echo "The diff command encountered an unexpected error!"
exit $error exit $error
fi fi
diff -u .tmp/$file.patch packages/kbn-handlebars/.patches/$file.patch set +e
diff -d --strip-trailing-cr $TMP/$file.patch packages/kbn-handlebars/.patches/$file.patch > $DEVNULL
error=$?
set -e
if [ $error -gt 1 ]
then
echo "The diff command encountered an unexpected error!"
exit $error
elif [ $error -gt 0 ]
then
echo
echo "The following files contain unexpected differences:"
echo
echo " Upstream: spec/$file.js"
echo " Downstream: packages/kbn-handlebars/src/upstream/index.$file.test.ts"
echo
echo "This can happen if either the upstream or the downstream version has been"
echo "updated without our patch files being kept up to date."
echo
echo "To resolve this issue, do the following:"
echo
echo " 1. Check the '4.x' branch of the upstream git repository to see if the file"
echo " has been updated. If so, please ensure that our copy of the file is kept in"
echo " sync. You can view the recent upstream commits to this file here:"
echo
echo " https://github.com/handlebars-lang/handlebars.js/commits/4.x/spec/$file.js"
echo
echo " 2. Update our patch files by running the following script. This is also"
echo " necessary even if it's only the downstream file that has been updated:"
echo
echo " ./packages/kbn-handlebars/scripts/update_test_patches.sh $file"
echo
echo " 3. Commit the changes to the updated patch file and execute this script again"
echo " until everything passes:"
echo
echo " ./packages/kbn-handlebars/scripts/check_for_test_changes.sh"
echo
exit $error
fi
done done
echo "No changes found :)" echo "No changes found :)"
rm -fr .tmp

View file

@ -1,12 +1,29 @@
#!/usr/bin/env bash
set -e set -e
rm -fr .tmp TMP=.tmp-handlebars
mkdir .tmp
function cleanup {
rm -fr $TMP
}
trap cleanup EXIT
rm -fr $TMP
mkdir $TMP
echo "Cloning handlebars repo..." echo "Cloning handlebars repo..."
git clone -q --depth 1 https://github.com/handlebars-lang/handlebars.js.git -b 4.x .tmp/handlebars git clone -q --depth 1 https://github.com/handlebars-lang/handlebars.js.git -b 4.x $TMP/handlebars
files=(packages/kbn-handlebars/src/upstream/index.*.test.ts) if [ -z "$1" ]
then
# No argument given: Update all patch files
files=(packages/kbn-handlebars/src/upstream/index.*.test.ts)
else
# Argument detected: Update only the requested patch file
files=(packages/kbn-handlebars/src/upstream/index.$1.test.ts)
fi
for file in "${files[@]}" for file in "${files[@]}"
do do
@ -15,10 +32,8 @@ do
echo "Overwriting stored patch file for spec/$file.js..." echo "Overwriting stored patch file for spec/$file.js..."
set +e set +e
diff .tmp/handlebars/spec/$file.js packages/kbn-handlebars/src/upstream/index.$file.test.ts > packages/kbn-handlebars/.patches/$file.patch diff -d --strip-trailing-cr $TMP/handlebars/spec/$file.js packages/kbn-handlebars/src/upstream/index.$file.test.ts > packages/kbn-handlebars/.patches/$file.patch
set -e set -e
done done
echo "All patches updated :)" echo "All patches updated :)"
rm -fr .tmp