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.1 to 0.1.2

41

Gruntfile.js

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

grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-contrib-jshint');

@@ -28,11 +30,10 @@ grunt.loadNpmTasks('grunt-mocha-cli');

jshint: {
all: [
'Gruntfile.js',
'tasks/**/*.js',
'test/*.js'
],
options: {
jshintrc: '.jshintrc',
ignores: []
}
},
task: [
'Gruntfile.js',
'tasks/**/*.js'
]
},

@@ -116,2 +117,18 @@

},
mochacli: {
options: {
questions: [
{
config: 'mochacli.options.reporter',
type: 'list',
message: 'Which Mocha reporter would you like to use?',
default: 'spec',
choices: ['dot', 'spec', 'nyan', 'TAP', 'landing', 'list',
'progress', 'json', 'JSONconv', 'HTMLconv', 'min', 'doc']
}
]
}
},
bump: {

@@ -192,6 +209,11 @@ options: {

mochacli: {
src: 'test/**/*.test.js',
options: {
reporter: 'spec'
},
all: ['test/*.test.js']
timeout: 10000,
ui: 'bdd',
reporter: 'spec',
require: [
'chai'
]
}
}

@@ -234,2 +256,3 @@ });

'jshint',
'prompt:mochacli',
'mochacli'

@@ -236,0 +259,0 @@ ]);

{
"name": "grunt-prompt",
"description": "Add interactive UI to your Gruntfile such as lists, checkboxes, text input with filtering, and password fields, all on the command line.",
"version": "0.1.1",
"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"
"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"
}
],
"main": "Gruntfile.js",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt test --stack"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.6",
"grunt": "~0.4.1",
"semver": "~2.0.10",
"grunt-mocha-cli": "~1.0.6"
},
"peerDependencies": {
"grunt": "~0.4.1"
},
"keywords": [
"gruntplugin"
],
"dependencies": {
"inquirer": "~0.2.1"
}
}

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

`Grunt-prompt`'s UI is powered by the amazing [Inquirer](https://github.com/SBoudrias/Inquirer.js), a project created by Simon Boudrias.
## Getting Started

@@ -34,10 +36,12 @@ This plugin requires Grunt `~0.4.1`

questions: [
config: 'config.name', // arbitray name or config for any other grunt task
type: '<question type>', // list, checkbox, confirm, input, password
message: 'Question to ask the user',
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
{
config: 'config.name', // arbitray name or config for any other grunt task
type: '<question type>', // list, checkbox, confirm, input, password
message: 'Question to ask the user',
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
}
]

@@ -50,5 +54,2 @@ }

The interactive prompts in `grunt-prompt` are generated by [Inquirer](https://github.com/SBoudrias/Inquirer.js) by @SBoudrias.
### Options

@@ -100,15 +101,7 @@

For `question type 'list'`: Type: `array of strings`
For `question types 'list' and 'checkbox'`: Type: `array of hashes`
```
choices: ['jshint', 'jslint', 'eslint', 'I like to live dangerously.']
```
If you want to specify the value for the choices then use this format:
For `question types 'checkbox' and 'list'`: Type: `array of hashes`
* `name` The label that is displayed in the UI.
* `value` _optional_ Value returned. When not used the name is used instead.
* `checked` Choosed the option by default.
* `checked` _optional_ Choosed the option by default. _Only for checkbox._

@@ -120,3 +113,3 @@ ```

{ name: 'eslint' },
{ name: 'something else', value: 'other' }
{ name: 'I like to live dangerously', value: 'none' }
]

@@ -144,3 +137,66 @@ ```

## How to use the results in your Gruntfile
You can also modify how tasks will work by changing options for other tasks.
You do not need to write code to do this, it's all in the `config` var.
Here we will let the user choose what Mocha reporter to use.
```js
config:
prompt: {
mochacli: {
options: {
questions: [
{
config: 'mochacli.options.reporter'
type: 'list'
message: 'Which Mocha reporter would you like to use?',
default: 'spec'
choices: ['dot', 'spec', 'nyan', 'TAP', 'landing', 'list',
'progress', 'json', 'JSONconv', 'HTMLconv', 'min', 'doc']
}
]
}
}
}
```
and create a shortcut:
```
grunt.registerTask('test',
[
'prompt:mochacli',
'mochacli'
]);
```
And run it:
```
$ grunt test
```
![prompt-mocha](https://f.cloud.github.com/assets/51505/983227/aabe4b6e-084a-11e3-94cd-514371c24059.gif)
## How can values be accessed from my own code?
This `config` value is accessible to all other `grunt` tasks via `grunt.config('<config name>')`.
If you had this:
```js
config: 'validation'
```
Then later on in your custom task can access it like this:
```js
var validation = grunt.config('validation');
```
### Usage Examples

@@ -147,0 +203,0 @@

@@ -1,9 +0,14 @@

/////////
// No automated testing at this time.
/////////
'use strict';
console.log("I'm not sure how to best write tests for this because it waits for user input before continuing.");
console.log("I tried using proxyquire but it doesn't seem possible to use it on grunt tasks because Grunt" +
"hides the require statement it uses.");
console.log("So for now just use grunt test to play with one of the configs manually.");
console.log("If you figure out a good way to write tests submit a pull request please!");
var expect = require('chai').expect;
describe('grunt-prompt', function(){
describe('silly stuff', function(){
it('loads', function(){
var prompt = require('../tasks/prompt');
expect(prompt).to.exist;
});
});
});

Sorry, the diff of this file is not supported yet

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