Skip to content

Commit 65d308d

Browse files
committed
Attempt to fix #1673
- added a test to demonstrate the regression - use duplicate-arguments-array, which correctly handles --amd --no-amd - unfortunately this breaks all other valid multi-keys like -k for known helpers :(
1 parent 3438891 commit 65d308d

File tree

2 files changed

+152
-138
lines changed

2 files changed

+152
-138
lines changed

bin/handlebars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env node
22

33
const yargs = require('yargs')
4+
.parserConfiguration({
5+
'duplicate-arguments-array': false
6+
})
47
.usage('Precompile handlebar templates.\nUsage: $0 [template|directory]...')
58
.option('f', {
69
type: 'string',

tasks/test-bin.js

Lines changed: 149 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,52 @@ chai.use(require('chai-diff'));
88
const expect = chai.expect;
99

1010
const testCases = [
11-
{
12-
binInputParameters: ['-a', 'spec/artifacts/empty.handlebars'],
13-
outputLocation: 'stdout',
14-
expectedOutputSpec: './spec/expected/empty.amd.js'
15-
},
16-
{
17-
binInputParameters: [
18-
'-a',
19-
'-f',
20-
'TEST_OUTPUT',
21-
'spec/artifacts/empty.handlebars'
22-
],
23-
outputLocation: 'TEST_OUTPUT',
24-
expectedOutputSpec: './spec/expected/empty.amd.js'
25-
},
26-
{
27-
binInputParameters: [
28-
'-a',
29-
'-n',
30-
'CustomNamespace.templates',
31-
'spec/artifacts/empty.handlebars'
32-
],
33-
outputLocation: 'stdout',
34-
expectedOutputSpec: './spec/expected/empty.amd.namespace.js'
35-
},
36-
{
37-
binInputParameters: [
38-
'-a',
39-
'--namespace',
40-
'CustomNamespace.templates',
41-
'spec/artifacts/empty.handlebars'
42-
],
43-
outputLocation: 'stdout',
44-
expectedOutputSpec: './spec/expected/empty.amd.namespace.js'
45-
},
46-
{
47-
binInputParameters: ['-a', '-s', 'spec/artifacts/empty.handlebars'],
48-
outputLocation: 'stdout',
49-
expectedOutputSpec: './spec/expected/empty.amd.simple.js'
50-
},
51-
{
52-
binInputParameters: ['-a', '-m', 'spec/artifacts/empty.handlebars'],
53-
outputLocation: 'stdout',
54-
expectedOutputSpec: './spec/expected/empty.amd.min.js'
55-
},
11+
// {
12+
// binInputParameters: ['-a', 'spec/artifacts/empty.handlebars'],
13+
// outputLocation: 'stdout',
14+
// expectedOutputSpec: './spec/expected/empty.amd.js'
15+
// },
16+
// {
17+
// binInputParameters: [
18+
// '-a',
19+
// '-f',
20+
// 'TEST_OUTPUT',
21+
// 'spec/artifacts/empty.handlebars'
22+
// ],
23+
// outputLocation: 'TEST_OUTPUT',
24+
// expectedOutputSpec: './spec/expected/empty.amd.js'
25+
// },
26+
// {
27+
// binInputParameters: [
28+
// '-a',
29+
// '-n',
30+
// 'CustomNamespace.templates',
31+
// 'spec/artifacts/empty.handlebars'
32+
// ],
33+
// outputLocation: 'stdout',
34+
// expectedOutputSpec: './spec/expected/empty.amd.namespace.js'
35+
// },
36+
// {
37+
// binInputParameters: [
38+
// '-a',
39+
// '--namespace',
40+
// 'CustomNamespace.templates',
41+
// 'spec/artifacts/empty.handlebars'
42+
// ],
43+
// outputLocation: 'stdout',
44+
// expectedOutputSpec: './spec/expected/empty.amd.namespace.js'
45+
// },
46+
// {
47+
// binInputParameters: ['-a', '-s', 'spec/artifacts/empty.handlebars'],
48+
// outputLocation: 'stdout',
49+
// expectedOutputSpec: './spec/expected/empty.amd.simple.js'
50+
// },
51+
// {
52+
// binInputParameters: ['-a', '-m', 'spec/artifacts/empty.handlebars'],
53+
// outputLocation: 'stdout',
54+
// expectedOutputSpec: './spec/expected/empty.amd.min.js'
55+
// },
56+
// This test now breaks...
5657
{
5758
binInputParameters: [
5859
'spec/artifacts/known.helpers.handlebars',
@@ -66,104 +67,114 @@ const testCases = [
6667
outputLocation: 'stdout',
6768
expectedOutputSpec: './spec/expected/non.empty.amd.known.helper.js'
6869
},
69-
{
70-
binInputParameters: ['--help'],
71-
outputLocation: 'stdout',
72-
expectedOutputSpec: './spec/expected/help.menu.txt'
73-
},
74-
{
75-
binInputParameters: ['-v'],
76-
outputLocation: 'stdout',
77-
expectedOutput: require('../package.json').version
78-
},
79-
{
80-
binInputParameters: [
81-
'-a',
82-
'-e',
83-
'hbs',
84-
'./spec/artifacts/non.default.extension.hbs'
85-
],
86-
outputLocation: 'stdout',
87-
expectedOutputSpec: './spec/expected/non.default.extension.amd.js'
88-
},
70+
// {
71+
// binInputParameters: ['--help'],
72+
// outputLocation: 'stdout',
73+
// expectedOutputSpec: './spec/expected/help.menu.txt'
74+
// },
75+
// {
76+
// binInputParameters: ['-v'],
77+
// outputLocation: 'stdout',
78+
// expectedOutput: require('../package.json').version
79+
// },
80+
// {
81+
// binInputParameters: [
82+
// '-a',
83+
// '-e',
84+
// 'hbs',
85+
// './spec/artifacts/non.default.extension.hbs'
86+
// ],
87+
// outputLocation: 'stdout',
88+
// expectedOutputSpec: './spec/expected/non.default.extension.amd.js'
89+
// },
90+
// {
91+
// binInputParameters: [
92+
// '-a',
93+
// '-p',
94+
// './spec/artifacts/partial.template.handlebars'
95+
// ],
96+
// outputLocation: 'stdout',
97+
// expectedOutputSpec: './spec/expected/partial.template.js'
98+
// },
99+
// {
100+
// binInputParameters: ['spec/artifacts/empty.handlebars', '-c'],
101+
// outputLocation: 'stdout',
102+
// expectedOutputSpec: './spec/expected/empty.common.js'
103+
// },
104+
// {
105+
// binInputParameters: [
106+
// 'spec/artifacts/empty.handlebars',
107+
// 'spec/artifacts/empty.handlebars',
108+
// '-a',
109+
// '-n',
110+
// 'someNameSpace'
111+
// ],
112+
// outputLocation: 'stdout',
113+
// expectedOutputSpec: './spec/expected/namespace.amd.js'
114+
// },
115+
// {
116+
// binInputParameters: [
117+
// 'spec/artifacts/empty.handlebars',
118+
// '-h',
119+
// 'some-path/',
120+
// '-a'
121+
// ],
122+
// outputLocation: 'stdout',
123+
// expectedOutputSpec: './spec/expected/handlebar.path.amd.js'
124+
// },
125+
// {
126+
// binInputParameters: [
127+
// 'spec/artifacts/partial.template.handlebars',
128+
// '-r',
129+
// 'spec',
130+
// '-a'
131+
// ],
132+
// outputLocation: 'stdout',
133+
// expectedOutputSpec: './spec/expected/empty.root.amd.js'
134+
// },
135+
// {
136+
// binInputParameters: [
137+
// '-i',
138+
// '<div>1</div>',
139+
// '-i',
140+
// '<div>2</div>',
141+
// '-N',
142+
// 'firstTemplate',
143+
// '-N',
144+
// 'secondTemplate',
145+
// '-a'
146+
// ],
147+
// outputLocation: 'stdout',
148+
// expectedOutputSpec: './spec/expected/empty.name.amd.js'
149+
// },
150+
// {
151+
// binInputParameters: [
152+
// '-i',
153+
// '<div>1</div>',
154+
// '-a',
155+
// '-m',
156+
// '-N',
157+
// 'test',
158+
// '--map',
159+
// './spec/tmp/source.map.amd.txt'
160+
// ],
161+
// outputLocation: 'stdout',
162+
// expectedOutputSpec: './spec/expected/source.map.amd.js'
163+
// },
164+
// {
165+
// binInputParameters: ['./spec/artifacts/bom.handlebars', '-b', '-a'],
166+
// outputLocation: 'stdout',
167+
// expectedOutputSpec: './spec/expected/bom.amd.js'
168+
// },
169+
// Issue #1673
89170
{
90171
binInputParameters: [
91-
'-a',
92-
'-p',
93-
'./spec/artifacts/partial.template.handlebars'
172+
'--amd',
173+
'--no-amd',
174+
'spec/artifacts/empty.handlebars'
94175
],
95176
outputLocation: 'stdout',
96-
expectedOutputSpec: './spec/expected/partial.template.js'
97-
},
98-
{
99-
binInputParameters: ['spec/artifacts/empty.handlebars', '-c'],
100-
outputLocation: 'stdout',
101177
expectedOutputSpec: './spec/expected/empty.common.js'
102-
},
103-
{
104-
binInputParameters: [
105-
'spec/artifacts/empty.handlebars',
106-
'spec/artifacts/empty.handlebars',
107-
'-a',
108-
'-n',
109-
'someNameSpace'
110-
],
111-
outputLocation: 'stdout',
112-
expectedOutputSpec: './spec/expected/namespace.amd.js'
113-
},
114-
{
115-
binInputParameters: [
116-
'spec/artifacts/empty.handlebars',
117-
'-h',
118-
'some-path/',
119-
'-a'
120-
],
121-
outputLocation: 'stdout',
122-
expectedOutputSpec: './spec/expected/handlebar.path.amd.js'
123-
},
124-
{
125-
binInputParameters: [
126-
'spec/artifacts/partial.template.handlebars',
127-
'-r',
128-
'spec',
129-
'-a'
130-
],
131-
outputLocation: 'stdout',
132-
expectedOutputSpec: './spec/expected/empty.root.amd.js'
133-
},
134-
{
135-
binInputParameters: [
136-
'-i',
137-
'<div>1</div>',
138-
'-i',
139-
'<div>2</div>',
140-
'-N',
141-
'firstTemplate',
142-
'-N',
143-
'secondTemplate',
144-
'-a'
145-
],
146-
outputLocation: 'stdout',
147-
expectedOutputSpec: './spec/expected/empty.name.amd.js'
148-
},
149-
{
150-
binInputParameters: [
151-
'-i',
152-
'<div>1</div>',
153-
'-a',
154-
'-m',
155-
'-N',
156-
'test',
157-
'--map',
158-
'./spec/tmp/source.map.amd.txt'
159-
],
160-
outputLocation: 'stdout',
161-
expectedOutputSpec: './spec/expected/source.map.amd.js'
162-
},
163-
{
164-
binInputParameters: ['./spec/artifacts/bom.handlebars', '-b', '-a'],
165-
outputLocation: 'stdout',
166-
expectedOutputSpec: './spec/expected/bom.amd.js'
167178
}
168179
];
169180

0 commit comments

Comments
 (0)