Skip to content

Commit 1e63cbf

Browse files
author
benholloway
committed
fix regression in defaults for init and webstorm tasks
1 parent 00a764e commit 1e63cbf

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

tasks/init.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ function setUpInitTask(context) {
3434
{
3535
key: 'defaults',
3636
value: {
37-
describe: 'Set defaults',
38-
alias : 'z',
39-
boolean : true,
40-
isOptional: true
37+
describe : 'Set defaults',
38+
alias : 'z',
39+
isOptional: true,
40+
default : false
4141
}
4242
},
4343
{
@@ -151,7 +151,7 @@ function setUpInitTask(context) {
151151
if (tyRun.checkFlagMissing(opt, key, value)) {
152152
return;
153153
}
154-
if (key !== 'port') {
154+
if ((key !== 'port') && (key !== 'defaults')) {
155155
// skip the valid types test for port, as will be done later
156156
// ensure options correspond to the types that they were defined as belonging to
157157
tyRun.checkFlagType(opt, key, value);
@@ -174,6 +174,11 @@ function setUpInitTask(context) {
174174
throw new Error('Port must be an integer, or "random"');
175175
}
176176
}
177+
else if (key === 'defaults') {
178+
if (!(/^(true|false|reset)$/.test(String(argv.defaults)))) {
179+
throw new Error('Unrecognised value for defaults flag, expected true|false|reset.');
180+
}
181+
}
177182
});
178183
return true;
179184
}
@@ -226,8 +231,8 @@ function setUpInitTask(context) {
226231
template = require('lodash.template'),
227232
merge = require('lodash.merge');
228233

229-
var hr = require('../lib/util/hr'),
230-
streams = require('../lib/config/streams');
234+
var hr = require('../lib/util/hr'),
235+
streams = require('../lib/config/streams');
231236

232237
var TEMPLATE_PATH = path.join(__dirname, '..', 'templates', 'angularity');
233238

tasks/webstorm.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ function setUpWebStormTask(context) {
3030
{
3131
key: 'defaults',
3232
value: {
33-
describe: 'Set defaults',
34-
alias : 'z',
35-
boolean : true,
36-
isOptional: true
33+
describe : 'Set defaults',
34+
alias : 'z',
35+
isOptional: true,
36+
default : false
3737
}
3838
},
3939
{
4040
key: 'subdir',
4141
value: {
42-
describe: 'Navigate to the sub-directory specified',
43-
alias : 's',
44-
string : true,
42+
describe : 'Navigate to the sub-directory specified',
43+
alias : 's',
44+
string : true,
4545
isOptional: true,
46-
default : config.get('subdir')
46+
default : config.get('subdir')
4747
}
4848
},
4949
{
@@ -108,7 +108,9 @@ function setUpWebStormTask(context) {
108108
}
109109

110110
// ensure options correspond to the types that they were defined as belonging to
111-
tyRun.checkFlagType(opt, key, value);
111+
if (key !== 'defaults') {
112+
tyRun.checkFlagType(opt, key, value);
113+
}
112114

113115
if (key === 'subdir') {
114116
var subdir = path.resolve(value);
@@ -117,6 +119,11 @@ function setUpWebStormTask(context) {
117119
throw new Error('The specified subdirectory does not exist.');
118120
}
119121
}
122+
else if (key === 'defaults') {
123+
if (!(/^(true|false|reset)$/.test(String(argv.defaults)))) {
124+
throw new Error('Unrecognised value for defaults flag, expected true|false|reset.');
125+
}
126+
}
120127
});
121128
if (!argv.defaults) {
122129
// when defaults are not present, check whether angularity project is present

0 commit comments

Comments
 (0)