├── .coveralls.yml ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jscsrc ├── .jshintignore ├── .jshintrc ├── .travis.yml ├── examples ├── with-co.js └── without-co.js ├── history.md ├── index.js ├── license.md ├── package.json ├── readme.md └── test.js /.coveralls.yml: -------------------------------------------------------------------------------- 1 | repo_token: Lp1BpivEcb0WHotTtsMqvrCfRiOnm90Zf 2 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # .editorconfig 2 | # 3 | # Copyright (c) 2014-2015 Charlike Mike Reagent, contributors. 4 | # Released under the MIT license. 5 | # 6 | 7 | root = true 8 | 9 | [*] 10 | indent_style = space 11 | charset = utf-8 12 | end_of_line = lf 13 | insert_final_newline = false 14 | trim_trailing_whitespace = false 15 | 16 | [*.{js,php}] 17 | indent_size = 2 18 | insert_final_newline = true 19 | trim_trailing_whitespace = true 20 | 21 | [*.{php,html}] 22 | indent_size = 4 23 | 24 | [*.{json,cson,yml,yaml,html,md,jade,css,stylus}] 25 | indent_size = 2 26 | 27 | [Makefile] 28 | indent_size = 2 29 | indent_style = tab 30 | 31 | [.*rc] 32 | indent_size = 2 33 | indent_style = space 34 | trim_trailing_whitespace = true -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # .gitattributes 2 | # 3 | # Copyright (c) 2014-2015 Charlike Mike Reagent, contributors. 4 | # Released under the MIT license. 5 | # 6 | 7 | # These settings are for any web project 8 | 9 | # Handle line endings automatically for files detected as text 10 | # and leave all files detected as binary untouched. 11 | 12 | * text=auto 13 | 14 | # 15 | # The above will handle all files NOT found below 16 | # These files are text and should be normalized (Convert crlf => lf) 17 | # 18 | 19 | *.php text 20 | *.css text 21 | *.js text 22 | *.htm text 23 | *.html text 24 | *.xml text 25 | *.txt text 26 | *.ini text 27 | *.inc text 28 | .htaccess text 29 | 30 | # 31 | # These files are binary and should be left untouched 32 | # (binary is a macro for -text -diff) 33 | # 34 | 35 | *.png binary 36 | *.jpg binary 37 | *.jpeg binary 38 | *.gif binary 39 | *.ico binary 40 | *.mov binary 41 | *.mp4 binary 42 | *.mp3 binary 43 | *.flv binary 44 | *.fla binary 45 | *.swf binary 46 | *.gz binary 47 | *.zip binary 48 | *.7z binary 49 | *.ttf binary 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # .gitignore 2 | # 3 | # Copyright (c) 2014-2015 Charlike Mike Reagent, contributors. 4 | # Released under the MIT license. 5 | # 6 | 7 | # Always-ignore dirs # 8 | # #################### 9 | _gh_pages 10 | node_modules 11 | bower_components 12 | components 13 | vendor 14 | build 15 | dest 16 | dist 17 | src 18 | lib-cov 19 | coverage 20 | nbproject 21 | cache 22 | temp 23 | tmp 24 | 25 | # Packages # 26 | # ########## 27 | *.7z 28 | *.dmg 29 | *.gz 30 | *.iso 31 | *.jar 32 | *.rar 33 | *.tar 34 | *.zip 35 | 36 | # OS, Logs and databases # 37 | # ######################### 38 | *.pid 39 | *.dat 40 | *.log 41 | *.sql 42 | *.sqlite 43 | *~ 44 | ~* 45 | 46 | # Another files # 47 | # ############### 48 | Icon? 49 | .DS_Store* 50 | Thumbs.db 51 | ehthumbs.db 52 | Desktop.ini 53 | npm-debug.log 54 | .directory 55 | ._* 56 | -------------------------------------------------------------------------------- /.jscsrc: -------------------------------------------------------------------------------- 1 | { 2 | "fileExtensions": [".js"], 3 | "maxErrors": 10, 4 | "esnext": true, 5 | "safeContextKeyword": ["self", "_this", "that"], 6 | 7 | "maximumLineLength": { 8 | "value": 80, 9 | "allowUrlComments": true, 10 | "allowComments": true, 11 | "allowRegex": true 12 | }, 13 | 14 | "validateQuoteMarks": "'", 15 | "validateIndentation": 2, 16 | 17 | "requireCurlyBraces": [ 18 | "if", 19 | "else", 20 | "for", 21 | "while", 22 | "do", 23 | "try", 24 | "catch" 25 | ], 26 | "requireSpaceAfterKeywords": [ 27 | "if", 28 | "else", 29 | "for", 30 | "while", 31 | "do", 32 | "switch", 33 | "case", 34 | "return", 35 | "try", 36 | "catch", 37 | "typeof" 38 | ], 39 | 40 | "requireCamelCaseOrUpperCaseIdentifiers": true, 41 | "requireSpacesInConditionalExpression": true, 42 | "requireSpaceBeforeBlockStatements": true, 43 | "requireSpaceBeforeBinaryOperators": true, 44 | "requireOperatorBeforeLineBreak": true, 45 | "requireCapitalizedConstructors": true, 46 | "requireParenthesesAroundIIFE": true, 47 | "requireCommaBeforeLineBreak": true, 48 | "requireLineFeedAtFileEnd": true, 49 | "requireDotNotation": true, 50 | 51 | "disallowYodaConditions": true, 52 | "disallowMultipleLineStrings": true, 53 | "disallowMultipleLineBreaks": true, 54 | "disallowMultipleVarDecl": true, 55 | "disallowMixedSpacesAndTabs": true, 56 | "disallowTrailingComma": true, 57 | "disallowTrailingWhitespace": true, 58 | "disallowSpaceAfterPrefixUnaryOperators": true, 59 | "disallowSpacesInsideObjectBrackets": "all", 60 | "disallowSpacesInsideParentheses": true, 61 | "disallowSpacesInsideArrayBrackets": true, 62 | "disallowNewlineBeforeBlockStatements": true, 63 | "disallowSpaceBeforePostfixUnaryOperators": true, 64 | "disallowImplicitTypeConversion": ["string"], 65 | "disallowKeywords": ["with"], 66 | "disallowKeywordsOnNewLine": ["else"], 67 | "disallowSpacesInCallExpression": true, 68 | 69 | "requireSpacesInFunctionExpression": { 70 | "beforeOpeningCurlyBrace": true 71 | }, 72 | "disallowSpacesInFunctionExpression": { 73 | "beforeOpeningRoundBrace": true 74 | }, 75 | "disallowSpacesInFunctionDeclaration": { 76 | "beforeOpeningRoundBrace": true 77 | }, 78 | 79 | "plugins": [ 80 | "jscs-jsdoc" 81 | ], 82 | "jsDoc": { 83 | "checkParamNames": true, 84 | "requireParamTypes": true, 85 | "checkRedundantParams": true, 86 | "checkReturnTypes": true, 87 | "checkRedundantReturns": true, 88 | "requireReturnTypes": true, 89 | "checkRedundantAccess": true, 90 | "checkTypes": "capitalizedNativeCase", 91 | "checkAnnotations": { 92 | "preset": "jsdoc3", 93 | "extra": { 94 | "api": true 95 | } 96 | } 97 | }, 98 | 99 | "excludeFiles": [ 100 | "_gh_pages/**", 101 | "node_modules/**", 102 | "bower_components/**", 103 | "components/**", 104 | "vendor/**", 105 | "build/**", 106 | "dest/**", 107 | "dist/**", 108 | "src/**", 109 | "lib-cov/**", 110 | "coverage/**", 111 | "nbproject/**", 112 | "cache/**", 113 | "temp/**", 114 | "tmp/**" 115 | ] 116 | } -------------------------------------------------------------------------------- /.jshintignore: -------------------------------------------------------------------------------- 1 | # .jshintignore 2 | # 3 | # Copyright (c) 2014-2015 Charlike Mike Reagent, contributors. 4 | # Released under the MIT license. 5 | # 6 | 7 | # Always-ignore dirs # 8 | # #################### 9 | _gh_pages 10 | node_modules 11 | bower_components 12 | components 13 | vendor 14 | build 15 | dest 16 | dist 17 | src 18 | lib-cov 19 | coverage 20 | nbproject 21 | cache 22 | temp 23 | tmp -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "maxerr" : 10, 3 | "indent" : 2, 4 | 5 | "maxparams" : 3, 6 | "maxdepth" : 3, 7 | "maxstatements" : 20, 8 | "maxlen" : 120, 9 | 10 | "camelcase" : true, 11 | "forin" : false, 12 | "immed" : true, 13 | "newcap" : true, 14 | "quotmark" : "single", 15 | 16 | "asi" : true, 17 | "eqnull" : true, 18 | "esnext" : true, 19 | "funcscope" : true, 20 | "globalstrict" : true, 21 | "lastsemic" : true, 22 | "shadow" : true, 23 | 24 | "node" : true, 25 | "nonstandard" : true, 26 | 27 | "globals": { 28 | "it": true, 29 | "describe": true, 30 | "beforeEach": true, 31 | "afterEach": true, 32 | "before": true, 33 | "after": true, 34 | "define": true, 35 | "should": true 36 | } 37 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: "node_js" 3 | node_js: 4 | - "iojs" 5 | - "0.10" 6 | - "0.11" 7 | - "0.12" 8 | matrix: 9 | allow_failures: 10 | - node_js: "0.10" 11 | fast_finish: true 12 | script: "npm run-script test-travis" 13 | after_script: "npm install coveralls && cat ./coverage/lcov.info | coveralls" -------------------------------------------------------------------------------- /examples/with-co.js: -------------------------------------------------------------------------------- 1 | /** 2 | * prompt-promise 3 | * 4 | * Copyright (c) 2014 Charlike Mike Reagent, contributors. 5 | * Released under the MIT license. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | var co = require('co'); 11 | var prompt = require('../index'); 12 | 13 | co(function * prompting() { 14 | var confirm = prompt.confirm; 15 | var password = prompt.password; 16 | var multiline = prompt.multiline; 17 | 18 | var username = yield prompt('username: '); 19 | var password = yield password('password: '); 20 | var description = yield multiline('description: '); 21 | var isOkey = yield confirm('Is okey?: '); 22 | 23 | return yield [username, password, description, isOkey]; 24 | }) 25 | .then(function fulfilled(val) { 26 | console.log('response:', val); 27 | }); -------------------------------------------------------------------------------- /examples/without-co.js: -------------------------------------------------------------------------------- 1 | /** 2 | * prompt-promise 3 | * 4 | * Copyright (c) 2014 Charlike Mike Reagent, contributors. 5 | * Released under the MIT license. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | var prompt = require('../index'); 11 | var result = []; 12 | 13 | // node < 0.11 14 | prompt('username: ') 15 | .then(function usernameResponse(val) { 16 | result.push(val); 17 | return prompt.password('password: '); 18 | }) 19 | .then(function passwordResponse(val) { 20 | result.push(val); 21 | return prompt.multiline('description: '); 22 | }) 23 | .then(function multilineResponse(val) { 24 | result.push(val); 25 | return prompt.confirm('Is this ok? (yes) '); 26 | }) 27 | .then(function confirmResponse(val) { 28 | result.push(val); 29 | console.log('response:', result); 30 | console.log('Done! :)'); 31 | }); 32 | -------------------------------------------------------------------------------- /history.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## v1.0.3 / January 31, 2015 4 | - Release v1.0.3 / npm@v1.0.3 5 | - update dotfiles 6 | - update license year 7 | - update scripts 8 | - update `without-co` example 9 | - add badges 10 | - update usage example 11 | - update deps versions ranges 12 | 13 | ## v1.0.2 / December 21, 2014 14 | - Release v1.0.2 / npm@v1.0.2 15 | - forgot to add bluebird in devDeps 16 | 17 | ## v1.0.1 / December 21, 2014 18 | - Release v1.0.1 / npm@v1.0.1 19 | - fix badge`s heading 20 | 21 | ## v1.0.0 / December 21, 2014 22 | - Release v1.0.0 / npm@v1.0.0 23 | - initial release 24 | 25 | ## v0.0.0 / December 20, 2014 26 | - init commits -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * prompt-promise 3 | * 4 | * Copyright (c) 2014-2015 Charlike Mike Reagent, contributors. 5 | * Released under the MIT license. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | var keypress = require('keypress'); 11 | var chalk = require('chalk'); 12 | var Deferred = require('native-or-another'); 13 | 14 | /** 15 | * Prompt for user input. 16 | */ 17 | exports = module.exports = prompt 18 | 19 | function prompt(msg, opts) { 20 | var defer = new Deferred(); 21 | opts = opts || {}; 22 | opts.bool = opts.bool || opts.boolCheck || opts.truthy || defaulBoolCheck; 23 | 24 | process.stdout.write(msg); 25 | process.stdin.setEncoding('utf8'); 26 | process.stdin.once('data', function(val) { 27 | if ((val.length - 1) === 0) { 28 | val = opts.default || ''; 29 | } 30 | if (opts.confirm) { 31 | defer.resolve(opts.bool(val)); 32 | process.stdin.pause(); 33 | return; 34 | } 35 | defer.resolve(val.trim()); 36 | process.stdin.pause(); 37 | }).resume() 38 | 39 | return defer.promise; 40 | } 41 | 42 | /** 43 | * Prompt for multi-line user input. 44 | */ 45 | exports.multiline = function(msg, opts) { 46 | var defer = new Deferred(); 47 | opts = opts || {}; 48 | 49 | var buf = []; 50 | process.stdout.write(msg); 51 | process.stdin.setEncoding('utf8'); 52 | process.stdin.on('data', function(val) { 53 | if (val === '\n' || val === '\r\n') { 54 | process.stdin.removeAllListeners('data'); 55 | if (buf.length === 0) { 56 | buf = [opts.default] || []; 57 | } 58 | defer.resolve(buf.join('\n')); 59 | process.stdin.pause(); 60 | } else { 61 | buf.push(val.trimRight()); 62 | } 63 | }).resume(); 64 | 65 | return defer.promise; 66 | }; 67 | 68 | /** 69 | * Prompt for confirmation. 70 | */ 71 | exports.confirm = function(msg, opts) { 72 | opts = opts || {}; 73 | opts.confirm = true; 74 | return prompt(msg, opts); 75 | }; 76 | 77 | /** 78 | * Prompt for password with optional mask. 79 | */ 80 | exports.password = function(msg, opts) { 81 | opts = opts || {}; 82 | opts.mask = !opts.mask ? '*' : opts.mask; 83 | var defer = new Deferred(); 84 | var buf = ''; 85 | 86 | keypress(process.stdin); 87 | process.stdin.setRawMode(true); 88 | process.stdout.write(msg); 89 | 90 | process.stdin.on('keypress', function onKeypress(c, key) { 91 | buf += c; 92 | 93 | if (key && key.name == 'backspace') { 94 | buf = buf.substring(0, buf.length - 2); 95 | process.stdout.clearLine(); 96 | process.stdout.cursorTo(0); 97 | process.stdout.write(msg + buf.split('').map(function replaceWithMask() { 98 | return opts.mask; 99 | }).join('')); 100 | return; 101 | } 102 | if (key && key.ctrl && key.name == 'c') { 103 | console.log(); 104 | process.exit(0); 105 | return; 106 | } 107 | if (key && key.name == 'return') { 108 | console.log(); 109 | process.stdin.pause(); 110 | process.stdin.removeAllListeners('keypress'); 111 | process.stdin.setRawMode(false); 112 | defer.resolve(buf.replace(/\r/g,'')); 113 | return; 114 | } 115 | 116 | process.stdout.write(opts.mask); 117 | }).resume(); 118 | 119 | return defer.promise; 120 | }; 121 | 122 | /** 123 | * Parse a boolean `str`. 124 | * 125 | * @param {String} str 126 | * @return {Boolean} 127 | * @api private 128 | */ 129 | function defaulBoolCheck(str) { 130 | return /^y(?:es)?|t(?:rue)?|ok(?:ey)?$/i.test(str); 131 | } 132 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2015 [Charlike Make Reagent](http://j.mp/1stW47C), contributors 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prompt-promise", 3 | "version": "1.0.3", 4 | "description": "Sane CLI user-input (command prompt, confirm, multiline, password) as promises, it can be used with co@4", 5 | "scripts": { 6 | "lint": "jshint index.js && jscs index.js --reporter inline", 7 | "test": "mocha", 8 | "test-cov": "istanbul cover _mocha", 9 | "test-travis": "istanbul cover _mocha --report lcovonly", 10 | "with-co": "node --harmony ./examples/with-co", 11 | "without-co": "node ./examples/without-co" 12 | }, 13 | "author": { 14 | "name": "Charlike Make Reagent", 15 | "email": "mameto_100@mail.bg", 16 | "url": "https://github.com/tunnckoCore" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git://github.com/tunnckoCore/prompt-promise.git" 21 | }, 22 | "keywords": [ 23 | "aplus", 24 | "cli", 25 | "co", 26 | "cojs", 27 | "command", 28 | "command-line", 29 | "command-prompt", 30 | "confirm", 31 | "console", 32 | "esnext", 33 | "generators", 34 | "input", 35 | "keypress", 36 | "line", 37 | "mask", 38 | "minimal", 39 | "multiline", 40 | "password", 41 | "pretty", 42 | "promises", 43 | "promises-aplus", 44 | "prompt", 45 | "prompts", 46 | "sane", 47 | "terminal", 48 | "tiny", 49 | "unobtrusive", 50 | "user", 51 | "user-input" 52 | ], 53 | "license": { 54 | "type": "MIT", 55 | "url": "https://github.com/tunnckoCore/prompt-promise/blob/master/license.md" 56 | }, 57 | "dependencies": { 58 | "chalk": "^2.0.1", 59 | "keypress": "~0.2.1", 60 | "native-or-another": "~2.0.0" 61 | }, 62 | "devDependencies": { 63 | "bluebird": "^2.4.1", 64 | "co": "^4.0.2", 65 | "istanbul-harmony": "^0.3.1", 66 | "mocha": "^2.0.1", 67 | "mocha-lcov-reporter": "^0.0.1" 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## [![npm][npmjs-img]][npmjs-url] [![mit license][license-img]][license-url] [![build status][travis-img]][travis-url] [![coverage status][coveralls-img]][coveralls-url] [![deps status][daviddm-img]][daviddm-url] 2 | 3 | > Sane CLI user-input (command prompt, confirm, multiline, password) as promises, it can be used with [co@4][co] 4 | 5 | ## Install 6 | ``` 7 | npm i --save prompt-promise 8 | ``` 9 | 10 | ## Run examples 11 | ``` 12 | npm run with-co 13 | npm run without-co 14 | ``` 15 | 16 | ## Usage 17 | > For more use-cases see [examples](./examples) 18 | 19 | ```js 20 | var co = require('co'); 21 | var prompt = require('prompt-promise'); 22 | var res = []; 23 | 24 | prompt('username: ') 25 | .then(function username(val) { 26 | res.push(val); 27 | return prompt.password('password: '); 28 | }) 29 | .then(function pasword(val) { 30 | res.push(val); 31 | console.log(res); 32 | }) 33 | 34 | // or with `co@4` 35 | co(function * genPrompt() { 36 | var username = yield prompt('username: '); 37 | var password = yield prompt.password('password: '); 38 | 39 | return yield [username, password]; 40 | }) 41 | .then(function fulfilled(array) { 42 | console.log('response:', array); 43 | }) 44 | ``` 45 | 46 | 47 | ## Author 48 | **Charlike Mike Reagent** 49 | + [gratipay/tunnckoCore][author-gratipay] 50 | + [twitter/tunnckoCore][author-twitter] 51 | + [github/tunnckoCore][author-github] 52 | + [npmjs/tunnckoCore][author-npmjs] 53 | + [more ...][contrib-more] 54 | 55 | 56 | ## License [![MIT license][license-img]][license-url] 57 | Copyright (c) 2014-2015 [Charlike Mike Reagent][contrib-more], [contributors][contrib-graf]. 58 | Copyright (c) 2014 [TJ Holowaychuk](https://github.com/tj), [contributors][contrib-graf]. 59 | Released under the [`MIT`][license-url] license. 60 | 61 | 62 | [npmjs-url]: http://npm.im/prompt-promise 63 | [npmjs-img]: https://img.shields.io/npm/v/prompt-promise.svg?style=flat&label=prompt-promise 64 | 65 | [coveralls-url]: https://coveralls.io/r/tunnckoCore/prompt-promise?branch=master 66 | [coveralls-img]: https://img.shields.io/coveralls/tunnckoCore/prompt-promise.svg?style=flat 67 | 68 | [license-url]: https://github.com/tunnckoCore/prompt-promise/blob/master/license.md 69 | [license-img]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat 70 | 71 | [travis-url]: https://travis-ci.org/tunnckoCore/prompt-promise 72 | [travis-img]: https://img.shields.io/travis/tunnckoCore/prompt-promise.svg?style=flat 73 | 74 | [daviddm-url]: https://david-dm.org/tunnckoCore/prompt-promise 75 | [daviddm-img]: https://img.shields.io/david/tunnckoCore/prompt-promise.svg?style=flat 76 | 77 | [author-gratipay]: https://gratipay.com/tunnckoCore 78 | [author-twitter]: https://twitter.com/tunnckoCore 79 | [author-github]: https://github.com/tunnckoCore 80 | [author-npmjs]: https://npmjs.org/~tunnckocore 81 | 82 | [contrib-more]: http://j.mp/1stW47C 83 | [contrib-graf]: https://github.com/tunnckoCore/prompt-promise/graphs/contributors 84 | 85 | *** 86 | 87 | _Powered and automated by [kdf](https://github.com/tunnckoCore), January 31, 2015_ 88 | 89 | [co]: https://github.com/tj/co -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * prompt-promise 3 | * 4 | * Copyright (c) 2014-2015 Charlike Mike Reagent, contributors. 5 | * Released under the MIT license. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | var promptPromise = require('./index'); 11 | 12 | // describe('prompt-promise', function() { 13 | // // body 14 | // }); 15 | 16 | var res = []; 17 | 18 | promptPromise('username: ') 19 | .then(function username(val) { 20 | res.push(val); 21 | return promptPromise.password('password: '); 22 | }) 23 | .then(function pasword(val) { 24 | res.push(val); 25 | console.log(res); 26 | }) --------------------------------------------------------------------------------