Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-prompt

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-prompt - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

90

Gruntfile.js

@@ -13,2 +13,4 @@ /*

var currentVersion = require('./package.json').version;
var chalk = require('chalk');
var _ = require('lodash');

@@ -50,13 +52,16 @@ module.exports = function (grunt) {

choices: [
{ name: 'White'.white },
{ name: 'Grey'.grey },
{ name: 'Blue'.blue },
{ name: 'Cyan'.cyan },
{ name: 'Green'.green },
{ name: 'Magenta'.magenta },
{ name: 'Red'.red },
{ name: 'Yellow'.yellow },
{ name: 'Rainbow'.rainbow }
{ name: chalk.white('White') },
{ name: chalk.grey('Grey') },
'---',
{ name: chalk.blue('Blue'), value: 'blue' },
{ name: chalk.cyan('Cyan') },
{ name: chalk.green('Green') },
{ name: chalk.magenta('Magenta') },
{ name: chalk.red('Red') },
{ name: chalk.yellow('Yellow') },
],
filter: String.toLowerCase
default: 'blue',
filter: function(str) {
return chalk.stripColor(str.toLowerCase());
}
},

@@ -68,19 +73,18 @@ {

choices: [
{ name: 'Bold'.bold },
{ name: 'Italic'.italic },
{ name: 'Underline'.underline },
{ name: 'Inverse'.inverse, value: 'inverse' },
{ name: 'Zebra'.zebra, value: 'zebra' }
{ name: chalk.bold('Bold'), value: 'bold' },
{ name: chalk.italic('Italic') },
{ name: chalk.underline('Underline'), value: 'underline' },
{ name: chalk.inverse('Inverse') },
{ name: chalk.strikethrough('Strikethrough') }
],
default: [
'bold', 'underline'
],
filter: function(value) {
return grunt.util._(value).map(String.toLowerCase);
},
validate: function(value) {
var inverseAndZebra = grunt.util._(['inverse', 'zebra']).all(function(val){
return grunt.util._(value).contains(val);
});
if (inverseAndZebra) {
return 'You can choose Inverse or Zebra but not both';
}
return true;
return _(value)
.map(chalk.stripColor)
.map(function(str){
return str.toLowerCase();
})
.value();
}

@@ -115,6 +119,25 @@ },

}
]
],
then: function(){
console.log(chalk.green.bold.underline('Great job!'));
}
}
},
test: {
options: {
questions: [
{
config: 'test',
type: 'input',
message: 'Just press enter, the result should be the default.',
default: 1
}
],
then: function(results){
console.log('results from this test', results);
}
}
},
mochacli: {

@@ -222,2 +245,14 @@ options: {

grunt.registerTask('results', 'show results from grunt-prompt', function(subtask){
_(grunt.config('prompt'))
.pick(subtask || _.constant(true))
.pluck('options')
.pluck('questions')
.flatten()
.pluck('config')
.each(function(key){
console.log(key + ':\t', grunt.config(key));
});
});
// Fake Grunt Bump task

@@ -264,4 +299,5 @@ grunt.registerTask('bump', '', function () {

'jshint',
'prompt:examples'
'prompt:examples',
'results:examples'
]);
};
{
"name": "grunt-prompt",
"description": "Add interactive console prompts to your Gruntfile such as lists, checkboxes, text input with filtering, and password fields.",
"version": "0.1.2",
"homepage": "https://github.com/dylang/grunt-prompt",
"author": {
"name": "Dylan Greene",
"email": "dylang@gmail.com",
"url": "http://doodleordie.com"
},
"repository": {
"type": "git",
"url": "git://github.com/dylang/grunt-prompt.git"
},
"bugs": {
"url": "https://github.com/dylang/grunt-prompt/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/dylang/grunt-prompt/blob/master/LICENSE-MIT"
}
],
"main": "Gruntfile.js",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt mochacli --stack"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.6",
"grunt": "~0.4.1",
"semver": "~2.1.0",
"grunt-mocha-cli": "~1.0.6",
"grunt-notify": "~0.2.10",
"chai": "~1.7.2"
},
"peerDependencies": {
"grunt": "~0.4.1"
},
"keywords": [
"gruntplugin",
"inquery",
"prompt",
"gui",
"console",
"terminal",
"UI",
"interactive",
"questions"
],
"dependencies": {
"inquirer": "~0.2.1"
"name": "grunt-prompt",
"description": "Add interactive console prompts to your Gruntfile such as lists, checkboxes, text input with filtering, and password fields.",
"version": "0.2.0",
"homepage": "https://github.com/dylang/grunt-prompt",
"author": {
"name": "Dylan Greene",
"email": "dylang@gmail.com",
"url": "http://doodleordie.com"
},
"repository": {
"type": "git",
"url": "git://github.com/dylang/grunt-prompt.git"
},
"bugs": {
"url": "https://github.com/dylang/grunt-prompt/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/dylang/grunt-prompt/blob/master/LICENSE-MIT"
}
],
"main": "Gruntfile.js",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt mochacli --stack"
},
"devDependencies": {
"lodash": "~2.4.1",
"grunt-contrib-jshint": "~0.8.0",
"grunt": "~0.4.1",
"semver": "~2.2.1",
"grunt-mocha-cli": "~1.5.0",
"grunt-notify": "~0.2.10",
"chai": "~1.8.1",
"chalk": "~0.4.0"
},
"peerDependencies": {
"grunt": "~0.4.1"
},
"keywords": [
"gruntplugin",
"inquery",
"prompt",
"gui",
"console",
"terminal",
"UI",
"interactive",
"questions"
],
"dependencies": {
"inquirer": "~0.4.0"
}
}

@@ -40,6 +40,6 @@ # grunt-prompt [![Build Status](https://travis-ci.org/dylang/grunt-prompt.png?branch=master)](https://travis-ci.org/dylang/grunt-prompt)

default: 'value', // default value if nothing is entered
choices: 'Array|Function(answers)',
validate: Function(value), // return true if valid, error message if invalid
filter: Function(value), // modify the answer
when: Function(answers) // only ask this question when this function returns true
choices: 'Array|function(answers)',
validate: function(value), // return true if valid, error message if invalid
filter: function(value), // modify the answer
when: function(answers) // only ask this question when this function returns true
}

@@ -93,5 +93,5 @@ ]

Type: `String`/`Array`/`Boolean` depending on `question type` _optional_
Type: `String`/`Array`/`Boolean`/'function' _optional_
Default value used when the user just bangs Enter.
Default value used when the user just hits Enter. *If a `value` field is not provided, the filter value must match the `name` exactly.*

@@ -104,3 +104,3 @@ #### choices

* `value` _optional_ Value returned. When not used the name is used instead.
* `checked` _optional_ Choosed the option by default. _Only for checkbox._
* `checked` _optional_ Choose the option by default. _Only for checkbox._

@@ -112,2 +112,3 @@ ```

{ name: 'eslint' },
'---', // puts in a non-selectable separator
{ name: 'I like to live dangerously', value: 'none' }

@@ -136,2 +137,8 @@ ]

#### then
Type: `function(results)` _optional_
Runs after all questions have been asked.
## How to use the results in your Gruntfile

@@ -138,0 +145,0 @@

@@ -20,3 +20,18 @@ /*

function addSeparator(choices) {
if (!choices) {
return choices;
}
return choices.map(function(choice){
if (choice === '---') {
return new inquirer.Separator();
}
return choice;
});
}
if (questions) {
var done = this.async();

@@ -26,7 +41,6 @@ questions = questions.map(function(question){

question.name = question.config || question.name;
question.choices = addSeparator(question.choices);
return question;
});
var done = this.async();
inquirer.prompt( questions, function( answers ) {

@@ -36,2 +50,5 @@ _(answers).forEach(function(answer, configName){

});
if (_.isFunction(options.then)) {
options.then(answers);
}
done();

@@ -38,0 +55,0 @@ });

@@ -11,2 +11,3 @@ 'use strict';

var prompt = require('../tasks/prompt');
console.log('--- The best way to test this is to just run `grunt` or `grunt prompt results`. ----')
expect(prompt).to.exist;

@@ -13,0 +14,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc