New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sync-prompt

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sync-prompt - npm Package Compare versions

Comparing version 0.2.2 to 0.3.1

coverage/coverage.json

10

HISTORY.md
# History
- v0.3.1
- a version bump from v0.3.0 to v0.3.1. There are absolutely no bug fixes in this one. I was simply not able to publish to v0.3.0, because I was too eager to publish to v0.3.0, but not actually wanting to publish it. But now, it seems NPM does not allow us to [overrite changes to a particular version](https://github.com/npm/npm-registry-couchapp/issues/148).
- v0.3.0
- added a `prompt.hidden` method
- deprecated the `hidden` parameter being passed to the `prompt` function, in favour of `prompt.hidden`. The parameter will still be available, just that it may be removed in a future release
- fixed a bug where a new-line was not appended after a hidden prompt
- added support for Node.js v0.11
- v0.2.2

@@ -10,3 +18,3 @@ - GCC 4.7 now successfully compiles sync-prompt

- v0.2.0
- added an optional paramter to `.prompt`--`hidden`. If set to true, the output will not be displayed as the user types. It's great for passwords
- added an optional parameter to `.prompt`--`hidden`. If set to true, the output will not be displayed as the user types. It's great for passwords
- some code formatting changes

@@ -13,0 +21,0 @@ - updates to unit tests

@@ -5,6 +5,38 @@ 'use strict';

module.exports.prompt = function (question, hidden) {
hidden = !!hidden;
var echoHidden = false;
function onExit() {
if (echoHidden) {
// This is just to clean up the part when the Node process is asked to exit
// during the time when the operating system was instructed to not echo out
// whatever is being typed to the console.
_syncPrompt.setStdinEcho(true);
echoHidden = false;
}
}
process.on('SIGINT', onExit);
process.on('exit', onExit);
module.exports.prompt = prompt;
function prompt(question, h) {
// The `h` parameter has been deprecated.
h = !!h;
if (typeof question == "string") { process.stdout.write(question); }
return hidden ? _syncPrompt.hiddenPrompt() : _syncPrompt.prompt();
};
return h ? hidden() : _syncPrompt.prompt();
}
module.exports.prompt.hidden = hidden;
function hidden(question) {
if (typeof question == 'string') { process.stdout.write(question); }
_syncPrompt.setStdinEcho(false);
// Just a flag to ensure emergency clean-up, just in case.
echoHidden = true;
var value = prompt();
console.log('');
_syncPrompt.setStdinEcho(true);
// Emergy clean-up not necessary, so set to false.
echoHidden = false;
return value;
}

2

package.json

@@ -10,3 +10,3 @@ {

],
"version": "0.2.2",
"version": "0.3.1",
"author": {

@@ -13,0 +13,0 @@ "name": "Salehen Shovon Rahman",

# sync-prompt
[![Build Status](https://travis-ci.org/shovon/sync-prompt.png)](https://travis-ci.org/shovon/sync-prompt) [![Dependency Status](https://gemnasium.com/shovon/sync-prompt.png)](https://gemnasium.com/shovon/sync-prompt) [![Coverage Status](https://coveralls.io/repos/shovon/sync-prompt/badge.png)](https://coveralls.io/r/shovon/sync-prompt)
[![Build Status](https://travis-ci.org/shovon/sync-prompt.png)](https://travis-ci.org/shovon/sync-prompt) [![Dependency Status](https://gemnasium.com/shovon/sync-prompt.png)](https://gemnasium.com/shovon/sync-prompt) [![Coverage Status](https://coveralls.io/repos/shovon/sync-prompt/badge.png)](https://coveralls.io/r/shovon/sync-prompt) [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=shovon&url=https://github.com/shovon/sync-prompt&title=Synchronous%20Prompt%20for%20Node.js&language=English&tags=github&category=software)

@@ -22,4 +22,3 @@ Synchronously prompt users for command-line input. Do more on Node.js, with less.

var hidden = true;
var password = prompt('Password: ', hidden);
var password = prompt.hidden('Password: ');
// User enters a password, but nothing will be written to the screen.

@@ -32,3 +31,3 @@ ```

When called, it will prompt the user for a command line input.
When called, it will prompt the user for a command-line input.

@@ -43,3 +42,3 @@ #### Parameters

**hidden**
**hidden** Deprecated

@@ -50,2 +49,14 @@ Type: `boolean`. Default value: undefined. Optional, but requires `question` to be set to a string.

### `.prompt.hidden([question])`
When called, it will prompt the user for a command-line input, while whatever is typed will not be echoed out to the screen.
#### Parameters
**question**
Type `string`. Default value: undefined. Optional
When set to a string, the value of `question` will be outputed to the console.
## Running Tests

@@ -52,0 +63,0 @@

@@ -14,3 +14,3 @@ /* globals describe, it, beforeEach, afterEach */

sinon.stub(_syncPrompt, 'prompt');
sinon.stub(_syncPrompt, 'hiddenPrompt');
sinon.stub(_syncPrompt, 'setStdinEcho');
});

@@ -21,3 +21,3 @@

_syncPrompt.prompt.restore();
_syncPrompt.hiddenPrompt.restore();
_syncPrompt.setStdinEcho.restore();
});

@@ -30,3 +30,3 @@

assert(_syncPrompt.prompt.called);
assert(!_syncPrompt.hiddenPrompt.called);
assert(!_syncPrompt.setStdinEcho.called);
});

@@ -41,3 +41,3 @@ });

assert(_syncPrompt.prompt.called);
assert(!_syncPrompt.hiddenPrompt.called);
assert(!_syncPrompt.setStdinEcho.called);
});

@@ -50,3 +50,3 @@

assert(_syncPrompt.prompt.called);
assert(!_syncPrompt.hiddenPrompt.called);
assert(!_syncPrompt.setStdinEcho.called);
});

@@ -56,6 +56,7 @@

// It's truthy, but not a string.
prompt(true);
assert(!process.stdout.write.called);
prompt.hidden();
assert(process.stdout.write.calledOnce);
assert(_syncPrompt.prompt.called);
assert(!_syncPrompt.hiddenPrompt.called);
assert(_syncPrompt.setStdinEcho.firstCall.calledWith(false));
assert(_syncPrompt.setStdinEcho.secondCall.calledWith(true));
});

@@ -65,8 +66,9 @@

var question = 'What is your name? ';
prompt(question, true);
prompt.hidden(question);
assert(process.stdout.write.calledWith(question));
assert(!_syncPrompt.prompt.called);
assert(_syncPrompt.hiddenPrompt.called);
assert(_syncPrompt.prompt.called);
assert(_syncPrompt.setStdinEcho.firstCall.calledWith(false));
assert(_syncPrompt.setStdinEcho.secondCall.calledWith(true));
});
});
});

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