Semantic-Org/gulp-prompt

Name: gulp-prompt

Owner: Semantic Org

Description: Add interactive console prompts to gulp

Forked from: Freyskeyd/gulp-prompt

Created: 2017-08-07 14:58:52.0

Updated: 2017-08-07 14:58:54.0

Pushed: 2017-08-07 15:48:06.0

Homepage: null

Size: 15

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Add interaction to gulp tasks.

.confirm([options])

Options:

This method will allow the pipe to continue if the user input is true, otherwise, it will be terminated.

Default usage:

.src('test.js')
.pipe(prompt.confirm())
.pipe(gulp.dest('dest'));

If a string is provided to the options, it will be set as the message:

.src('test.js')
.pipe(prompt.confirm('Are you ready for Gulp?'))
.pipe(gulp.dest('dest'));

Example when using options:

.src('test.js')
.pipe(prompt.confirm({
    message: 'Continue?',
    default: true
}))
.pipe(gulp.dest('dest'));
.prompt(questions, callback)

This is a clean pass-through function for gulp to utilize the full Inquirer.js Library, please refer to them for documentation on corresponding parameters.

Please note that all types are avaiable, not just the examples below.

Example Input:

.src('test.js')
.pipe(prompt.prompt({
    type: 'input',
    name: 'task',
    message: 'Which task would you like to run?'
}, function(res){
    //value is in res.task (the name option gives the key)
}));

Example Checkbox:

.src('test.js')
.pipe(prompt.prompt({
    type: 'checkbox',
    name: 'bump',
    message: 'What type of bump would you like to do?',
    choices: ['patch', 'minor', 'major']
}, function(res){
    //value is in res.bump (as an array)
}));

Example Password:

.src('test.js')
.pipe(prompt.prompt({
    type: 'password',
    name: 'pass',
    message: 'Please enter your password'
}, function(res){
    //value is in res.pass
}));

Example Multiple:

.src('test.js')
.pipe(prompt.prompt([{
    type: 'input',
    name: 'first',
    message: 'First question?'
},
{
    type: 'input',
    name: 'second',
    message: 'Second question?'
}], function(res){
    //value is in res.first and res.second
}));

Example Validation:

.src('test.js')
.pipe(prompt.prompt({
    type: 'password',
    name: 'pass',
    message: 'Please enter your password',
    validate: function(pass){

        if(pass !== '123456'){
            return false;
        }

        return true;
    }
}, function(res){
    //value is in res.pass
}));

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.