npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-prompt

v1.2.0

Published

Add interactive console prompts to gulp

Downloads

40,529

Readme

Gulp prompt

If you are interested in getting involved please send us an e-mail or open an issue. There are a couple of open issues and small clean up projects that we could use some help with.

Add interaction to gulp tasks.

.confirm([options])

Options:

  • message - Message to be displayed
  • default - Default response if none is provided

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

Default usage:


gulp.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:


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

Example when using options:


gulp.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:


gulp.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:


gulp.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:


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

Example Multiple:


gulp.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:


gulp.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
	}));

Example List Selection: Note: see sample file


    gulp.src( './package.json' )
        .pipe( prompt.prompt({
            type:'list',
            name:'env',
            message:'Please enter selection?',
            choices: ['a','b','c','d','e','f', 'g', 'h'],
            pageSize:'3'
        }, (res) => {
            console.log('Result', res);
        }) );

Example Templating: This was a fix to the issue #8 (https://github.com/Freyskeyd/gulp-prompt/issues/8) Note: see sample file


    return gulp.src( './package.json' )
        .pipe( prompt.confirm({
            type:'input',
            name:'env',
            message:'Hello <%= user %>, please enter selection?',
            templateOptions:{ 'user': 'fred' }
        }, (res) => {
            console.log('Result', res);
        }) );

Example Chaining Prompts: This was a fix to the issue #35 (https://github.com/Freyskeyd/gulp-prompt/issues/35) This was a fix to the issue #34 (https://github.com/Freyskeyd/gulp-prompt/issues/34) Note: see sample file


	var index =0;

	var chainFunction = function ( options, resp ){
		console.log( 'Here is the selection ', resp);
		if( index <= 3){
			options.message = `Hello this is iteration ${index}`;
			index++;
			return options;
		}else{
			return;
		}
	};

	gulp.task( 'chainConfirm',  () => {
		return gulp.src( '../package.json' )
			.pipe( prompt.confirm({
				type:'input',
				name:'env',
				message:'Hello First interation, please enter selection?',
				chainFunction:chainFunction
			}, (res) => {
				console.log('Result', res);
			}) );
	});

This was a fix to the issue #60 (https://github.com/Freyskeyd/gulp-prompt/issues/60) Note: see sample file


	var index =0;

	var chainFunction = function ( options, resp ){
		console.log( 'Here is the selection ', resp);
		if( index <= 3){
			options.message = `Hello this is iteration ${index}`;
			index++;
			return options;
		}else{
			return;
		}
	};

	gulp.task( 'chainConfirm',  () => {
		return gulp.src( '../package.json' )
			.pipe( prompt.prompt({
				type:'input',
				name:'env',
				message:'Hello First interation, please enter selection?',
				chainFunction:chainFunction
			}, (res) => {
				console.log('Result', res);
			}) );
	});