Skip to content

Commit

Permalink
Add an automatic reinstallation process based on semantic.json
Browse files Browse the repository at this point in the history
This feature is added to allow to automatize a semantic-ui
reinstallation with the same configuration (such as in your CI build)

To switch it on, simply add ("auto-install": true) in semantic.json
  • Loading branch information
Olivier Morel committed Jan 27, 2016
1 parent 7599cf8 commit 8e272ac
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 21 deletions.
15 changes: 13 additions & 2 deletions tasks/config/project/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ module.exports = {
{
name: 'Yes',
value: true
},
}
]
},
{
Expand Down Expand Up @@ -730,7 +730,7 @@ module.exports = {

/* Rename Files */
rename: {
json : { extname : '.json' },
json : { extname : '.json' }
},

/* Copy Install Folders */
Expand All @@ -751,6 +751,17 @@ module.exports = {
}

}
},

// Detect whether there is a semantic.json configuration and that the auto-install option is set to True
// Returns the semantic.json configuration
autoInstall: function() {
var config = when.hasConfig();
if (config && config['auto-install']) {
return when.hasConfig();
} else {
return false;
}
}

};
47 changes: 28 additions & 19 deletions tasks/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,17 @@ if(manager.name == 'NPM') {

gulp.task('run setup', function() {

return gulp
.src('gulpfile.js')
.pipe(prompt.prompt(questions.setup, function(setupAnswers) {
// hoist
answers = setupAnswers;
}))
;

// If auto-install is switched on, we skip the configuration section and simply reuse the configuration from semantic.json
if (install.autoInstall()) {
answers = install.autoInstall();
} else {
return gulp
.src('gulpfile.js')
.pipe(prompt.prompt(questions.setup, function(setupAnswers) {
// hoist
answers = setupAnswers;
}));
}
});

gulp.task('create install files', function(callback) {
Expand Down Expand Up @@ -414,17 +417,23 @@ gulp.task('clean up install', function() {
console.log('');
}

return gulp
.src('gulpfile.js')
.pipe(prompt.prompt(questions.cleanup, function(answers) {
if(answers.cleanup == 'yes') {
del(install.setupFiles);
}
if(answers.build == 'yes') {
gulp.start('build');
}
}))
;
// If auto-install is switched on, we skip the configuration section and simply build the dependencies
if (install.autoInstall()) {
return gulp.start('build');
} else {
return gulp
.src('gulpfile.js')
.pipe(prompt.prompt(questions.cleanup, function(answers) {
if(answers.cleanup == 'yes') {
del(install.setupFiles);
}
if(answers.build == 'yes') {
gulp.start('build');
}
}));
}


});

runSequence(
Expand Down

0 comments on commit 8e272ac

Please sign in to comment.