Skip to content

Commit 487c5cc

Browse files
committed
Semantic-Org#3616 Adds autoInstall option to semantic.json, modifies installer to return correct questions object in autoinstall
1 parent 33381f5 commit 487c5cc

File tree

4 files changed

+43
-38
lines changed

4 files changed

+43
-38
lines changed

RELEASE-NOTES.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22

33
### Version 2.1.9 - Feb 15, 2016
44

5+
56
**Bugs**
67
-**Dropdown** - Fixed issue where dropdowns with sub-menus would not properly activate on mobile #3183
78
-**API** - Fixes bug where `beforeSend` would not correctly cancel request when `return false;` is used in callback. #3660
89

910

1011

11-
**Enhancements**
12-
13-
14-
1512
### Version 2.1.8 - Jan 7, 2016
1613

1714
**Critical Fix**

semantic.json.example

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
},
1919

2020
"permission" : false,
21+
"autoInstall": false,
2122
"rtl": false
2223

2324
}

tasks/config/project/install.js

+8-12
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ module.exports = {
8282
return when.hasConfig();
8383
},
8484

85+
// detect whether there is a semantic.json configuration and that the auto-install option is set to true
86+
shouldAutoInstall: function() {
87+
var
88+
config = when.hasConfig()
89+
;
90+
return config['autoInstall'];
91+
},
92+
8593
// checks if files are in a PM directory
8694
getPackageManager: function(directory) {
8795
var
@@ -751,17 +759,5 @@ module.exports = {
751759
}
752760

753761
}
754-
},
755-
756-
// Detect whether there is a semantic.json configuration and that the auto-install option is set to True
757-
// Returns the semantic.json configuration
758-
autoInstall: function() {
759-
var config = when.hasConfig();
760-
if (config && config['auto-install']) {
761-
return when.hasConfig();
762-
} else {
763-
return false;
764-
}
765762
}
766-
767763
};

tasks/install.js

+33-22
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,20 @@ if(manager.name == 'NPM') {
192192
gulp.task('run setup', function() {
193193

194194
// If auto-install is switched on, we skip the configuration section and simply reuse the configuration from semantic.json
195-
if (install.autoInstall()) {
196-
answers = install.autoInstall();
197-
} else {
195+
if(install.shouldAutoInstall()) {
196+
answers = {
197+
overwrite : 'yes',
198+
install : 'auto',
199+
};
200+
}
201+
else {
198202
return gulp
199-
.src('gulpfile.js')
200-
.pipe(prompt.prompt(questions.setup, function(setupAnswers) {
201-
// hoist
202-
answers = setupAnswers;
203-
}));
203+
.src('gulpfile.js')
204+
.pipe(prompt.prompt(questions.setup, function(setupAnswers) {
205+
// hoist
206+
answers = setupAnswers;
207+
}))
208+
;
204209
}
205210
});
206211

@@ -214,9 +219,13 @@ gulp.task('create install files', function(callback) {
214219
if(answers.overwrite !== undefined && answers.overwrite == 'no') {
215220
return;
216221
}
217-
218222
console.clear();
219-
console.log('Installing');
223+
if(install.shouldAutoInstall()) {
224+
console.log('Auto-Installing (Without User Interaction)');
225+
}
226+
else {
227+
console.log('Installing');
228+
}
220229
console.log('------------------------------');
221230

222231

@@ -418,19 +427,21 @@ gulp.task('clean up install', function() {
418427
}
419428

420429
// If auto-install is switched on, we skip the configuration section and simply build the dependencies
421-
if (install.autoInstall()) {
430+
if(install.shouldAutoInstall()) {
422431
return gulp.start('build');
423-
} else {
432+
}
433+
else {
424434
return gulp
425-
.src('gulpfile.js')
426-
.pipe(prompt.prompt(questions.cleanup, function(answers) {
427-
if(answers.cleanup == 'yes') {
428-
del(install.setupFiles);
429-
}
430-
if(answers.build == 'yes') {
431-
gulp.start('build');
432-
}
433-
}));
435+
.src('gulpfile.js')
436+
.pipe(prompt.prompt(questions.cleanup, function(answers) {
437+
if(answers.cleanup == 'yes') {
438+
del(install.setupFiles);
439+
}
440+
if(answers.build == 'yes') {
441+
gulp.start('build');
442+
}
443+
}))
444+
;
434445
}
435446

436447

@@ -443,4 +454,4 @@ runSequence(
443454
callback
444455
);
445456

446-
};
457+
};

0 commit comments

Comments
 (0)