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

prompt

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prompt - npm Package Compare versions

Comparing version 0.1.5 to 0.1.7

5

lib/prompt.js

@@ -190,2 +190,3 @@ /*

var name = prop.message || prop.name || prop,
propName = prop.name || prop,
delim = prompt.delimiter + ' ',

@@ -196,2 +197,6 @@ raw = [prompt.message, delim + name.grey, delim.grey],

if (prompt.override && prompt.override [propName]) {
return callback (null, prompt.override [propName])
}
if (prop.default) {

@@ -198,0 +203,0 @@ raw.splice(2, -1, ' (' + prop.default + ')');

2

package.json
{
"name": "prompt",
"description": "A beautiful command-line prompt for node.js",
"version": "0.1.5",
"version": "0.1.7",
"author": "Nodejitsu Inc. <info@nodejitsu.com>",

@@ -6,0 +6,0 @@ "contributors": [

@@ -126,3 +126,41 @@ # node-prompt

```
### skipping prompts
Sometimes power users may wish to skip promts and specify all data as command line options.
if a value is set as a property of `prompt.override` prompt will use that instead of
prompting the user.
``` js
//prompt-everride.js
var prompt = require('prompt'),
optimist = require('optimist')
//
// set the overrides
//
prompt.override = optimist.argv
//
// Start the prompt
//
prompt.start();
//
// Get two properties from the user: username and email
//
prompt.get(['username', 'email'], function (err, result) {
//
// Log the results.
//
console.log('Command-line input received:');
console.log(' username: ' + result.username);
console.log(' email: ' + result.email);
})
//: node prompt-everride.js --username USER --email EMAIL
```
### Adding Properties to an Object

@@ -129,0 +167,0 @@ A common use-case for prompting users for data from the command-line is to extend or create a configuration object that is passed onto the entry-point method for your CLI tool. `node-prompt` exposes a convenience method for doing just this:

@@ -272,3 +272,12 @@ /*

}
}
}/*,
"skip prompt with prompt.overide": {
topic: function () {
prompt.overide = { coconihet: 'whatever' }
prompt.get('coconihet', this.callback);
},
"skips prompt and uses overide": function (err, results) {
assert.equal(results.coconihet, 'whatever')
}
}*/
},

@@ -320,2 +329,64 @@ "the addProperties() method": {

}
}).addBatch({
"when using node-prompt": {
topic: function () {
//
// Reset the prompt for mock testing
//
prompt.started = false;
prompt.start({
stdin: helpers.stdin,
stdout: helpers.stdout
});
return null;
},
"the get() method": {
topic: function () {
prompt.override = { xyz: 468, abc: 123 }
prompt.get(['xyz', 'abc'], this.callback);
},
"should respond with overrides": function (err, results) {
assert.isNull(err);
assert.deepEqual(results, { xyz: 468, abc: 123 });
}
}
}
}).addBatch({
"when using node-prompt": {
topic: function () {
//
// Reset the prompt for mock testing
//
prompt.started = false;
prompt.start({
stdin: helpers.stdin,
stdout: helpers.stdout
});
return null;
},
"with fancy properties": {
"the get() method": {
topic: function () {
prompt.override = { UVW: 5423, DEF: 64235 }
prompt.get([{
name:'UVW',
message: 'a custom message',
default: 6
},{
name:'DEF',
message: 'a custom message',
default: 6
}], this.callback);
},
"should respond with overrides": function (err, results) {
assert.isNull(err);
assert.deepEqual(results, { UVW: 5423, DEF: 64235 });
}
}
}
}
}).export(module);
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