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

promptly

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promptly - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

bleh.js

8

index.js

@@ -6,8 +6,2 @@ 'use strict';

var parseMessage = function(message, opts) {
return (opts.hasOwnProperty('default') && opts.default != '')
? message + ' (' + opts.default + '):'
: message + ':';
}
promptly.prompt = function (message, opts, fn) {

@@ -31,3 +25,3 @@ // Arguments parsing

var readOpts = {
prompt: parseMessage(message, opts),
prompt: message,
input: opts.input || process.stdin,

@@ -34,0 +28,0 @@ output: opts.output || process.stdout,

{
"name": "promptly",
"version": "1.1.0",
"version": "2.0.0",
"description": "Simple command line prompting utility",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -28,3 +28,3 @@ 'use strict';

it('should prompt the user', function (next) {
promptly.prompt('something', function (err, value) {
promptly.prompt('something: ', function (err, value) {
expect(err).to.be(null);

@@ -40,3 +40,3 @@ expect(value).to.be('yeaa');

it('should keep asking if no value is passed and no default was defined', function (next) {
promptly.prompt('something', function (err, value) {
promptly.prompt('something: ', function (err, value) {
expect(err).to.be(null);

@@ -55,6 +55,6 @@ expect(value).to.be('yeaa');

it('should assume default value if nothing is passed', function (next) {
promptly.prompt('something', { 'default': 'myValue' }, function (err, value) {
promptly.prompt('something: ', { 'default': 'myValue' }, function (err, value) {
expect(err).to.be(null);
expect(value).to.be('myValue');
expect(stdout).to.contain('something (myValue):');
expect(stdout).to.contain('something: ');
next();

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

it('should trim the user input if trim is enabled', function (next) {
promptly.prompt('something', { trim: true }, function (err, value) {
promptly.prompt('something: ', { trim: true }, function (err, value) {
expect(err).to.be(null);

@@ -87,3 +87,3 @@ expect(value).to.be('yeaa');

promptly.prompt('something', { validator: validator, retry: false }, function (err, value) {
promptly.prompt('something: ', { validator: validator, retry: false }, function (err, value) {
expect(err).to.be(null);

@@ -101,3 +101,3 @@ expect(value).to.be('yeaa');

promptly.prompt('something', { validator: validator }, function (err, value) {
promptly.prompt('something: ', { validator: validator }, function (err, value) {
expect(err).to.be(null);

@@ -121,3 +121,3 @@ expect(value).to.be('bla');

promptly.prompt('something', { validator: validator, retry: true }, function (err, value) {
promptly.prompt('something: ', { validator: validator, retry: true }, function (err, value) {
expect(stdout).to.contain('something: ');

@@ -137,3 +137,3 @@ expect(stdout.indexOf('something')).to.not.be(stdout.lastIndexOf('something'));

promptly.prompt('something', { validator: validator, retry: false }, function (err) {
promptly.prompt('something: ', { validator: validator, retry: false }, function (err) {
expect(err).to.be.an(Error);

@@ -159,3 +159,3 @@ expect(err.message).to.be('bla');

promptly.prompt('something', { validator: validator, retry: false }, function (err, value) {
promptly.prompt('something: ', { validator: validator, retry: false }, function (err, value) {
times++;

@@ -179,3 +179,3 @@

it('should write input to stdout by default', function (next) {
promptly.prompt('something', function (err, value) {
promptly.prompt('something: ', function (err, value) {
expect(err).to.be(null);

@@ -192,3 +192,3 @@ expect(value).to.be('yeaa');

it('should write input to stdout if silent is false', function (next) {
promptly.prompt('something', { silent: true }, function (err, value) {
promptly.prompt('something: ', { silent: true }, function (err, value) {
expect(err).to.be(null);

@@ -207,6 +207,6 @@ expect(value).to.be('yeaa');

it('should keep asking on invalid choice', function (next) {
promptly.choose('apple or orange', ['apple', 'orange'], function (err, value) {
promptly.choose('apple or orange? ', ['apple', 'orange'], function (err, value) {
expect(err).to.be(null);
expect(value).to.be('orange');
expect(stdout).to.contain('apple or orange: ');
expect(stdout).to.contain('apple or orange? ');
expect(stdout.indexOf('apple or orange')).to.not.be(stdout.lastIndexOf('apple or orange'));

@@ -222,6 +222,6 @@ expect(stdout).to.contain('Invalid choice');

it('should error on invalid choice if retry is disabled', function (next) {
promptly.choose('apple or orange', ['apple', 'orange'], { retry: false }, function (err) {
promptly.choose('apple or orange? ', ['apple', 'orange'], { retry: false }, function (err) {
expect(err).to.be.an(Error);
expect(err.message).to.contain('choice');
expect(stdout).to.contain('apple or orange: ');
expect(stdout).to.contain('apple or orange? ');
next();

@@ -234,6 +234,6 @@ });

it('should be ok on valid choice', function (next) {
promptly.choose('apple or orange', ['apple', 'orange'], function (err, value) {
promptly.choose('apple or orange? ', ['apple', 'orange'], function (err, value) {
expect(err).to.be(null);
expect(value).to.be('apple');
expect(stdout).to.contain('apple or orange: ');
expect(stdout).to.contain('apple or orange? ');
next();

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

it('should not use strict comparison when matching against valid choices', function (next) {
promptly.choose('choices', [1, 2, 3], function (err, value) {
promptly.choose('choices: ', [1, 2, 3], function (err, value) {
expect(err).to.be(null);

@@ -262,6 +262,6 @@ expect(typeof value).to.equal('number');

async.forEachSeries(['yes', 'Y', 'y', '1'], function (truthy, next) {
promptly.confirm('test yes', { retry: false }, function (err, value) {
promptly.confirm('test yes? ', { retry: false }, function (err, value) {
expect(err).to.be(null);
expect(value).to.be(true);
expect(stdout).to.contain('test yes: ');
expect(stdout).to.contain('test yes? ');
next();

@@ -273,6 +273,6 @@ });

async.forEachSeries(['no', 'N', 'n', '0'], function (truthy, next) {
promptly.confirm('test no', function (err, value) {
promptly.confirm('test no? ', function (err, value) {
expect(err).to.be(null);
expect(value).to.be(false);
expect(stdout).to.contain('test no: ');
expect(stdout).to.contain('test no? ');
next();

@@ -287,6 +287,6 @@ });

it('should keep asking on invalid choice', function (next) {
promptly.confirm('yes or no', function (err, value) {
promptly.confirm('yes or no? ', function (err, value) {
expect(err).to.be(null);
expect(value).to.be(true);
expect(stdout).to.contain('yes or no: ');
expect(stdout).to.contain('yes or no? ');
expect(stdout.indexOf('yes or no')).to.not.be(stdout.lastIndexOf('yes or no'));

@@ -301,6 +301,6 @@ next();

it('should error on invalid choice if retry is disabled', function (next) {
promptly.confirm('yes or no', { retry: false }, function (err) {
promptly.confirm('yes or no? ', { retry: false }, function (err) {
expect(err).to.be.an(Error);
expect(err.message).to.not.contain('Invalid choice');
expect(stdout).to.contain('yes or no: ');
expect(stdout).to.contain('yes or no? ');
next();

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

it('should prompt the user silently', function (next) {
promptly.password('something', function (err, value) {
promptly.password('something: ', function (err, value) {
expect(value).to.be('yeaa');

@@ -328,3 +328,3 @@ expect(stdout).to.contain('something: ');

it('should not trim by default', function (next) {
promptly.password('something', function (err, value) {
promptly.password('something: ', function (err, value) {
expect(value).to.be(' yeaa ');

@@ -341,3 +341,3 @@ expect(stdout).to.contain('something: ');

it('show allow empty passwords by default', function (next) {
promptly.password('something', function (err, value) {
promptly.password('something: ', function (err, value) {
expect(value).to.be('');

@@ -344,0 +344,0 @@ expect(stdout).to.contain('something: ');

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