@inquirer/core
Advanced tools
Comparing version 0.0.10-alpha.0 to 0.0.11-alpha.0
22
hooks.js
@@ -12,3 +12,3 @@ const readline = require('readline'); | ||
const cleanupHook = index => { | ||
const cleanupHook = (index) => { | ||
const cleanFn = hooksCleanup[index]; | ||
@@ -20,3 +20,3 @@ if (typeof cleanFn === 'function') { | ||
exports.useState = defaultValue => { | ||
exports.useState = (defaultValue) => { | ||
const _idx = index; | ||
@@ -29,3 +29,3 @@ const value = _idx in hooks ? hooks[_idx] : defaultValue; | ||
value, | ||
newValue => { | ||
(newValue) => { | ||
hooks[_idx] = newValue; | ||
@@ -35,7 +35,7 @@ | ||
handleChange(); | ||
} | ||
}, | ||
]; | ||
}; | ||
exports.useKeypress = userHandler => { | ||
exports.useKeypress = (userHandler) => { | ||
const _idx = index; | ||
@@ -77,8 +77,8 @@ const prevHandler = hooks[_idx]; | ||
exports.useRef = val => { | ||
exports.useRef = (val) => { | ||
return exports.useState({ current: val })[0]; | ||
}; | ||
exports.createPrompt = view => { | ||
return options => { | ||
exports.createPrompt = (view) => { | ||
return (options) => { | ||
// Default `input` to stdin | ||
@@ -94,3 +94,3 @@ const input = process.stdin; | ||
input, | ||
output | ||
output, | ||
}); | ||
@@ -102,3 +102,3 @@ const screen = new ScreenManager(rl); | ||
const done = value => { | ||
const done = (value) => { | ||
let len = cleanupHook.length; | ||
@@ -120,3 +120,3 @@ while (len--) { | ||
hooks = []; | ||
const workLoop = config => { | ||
const workLoop = (config) => { | ||
index = 0; | ||
@@ -123,0 +123,0 @@ handleChange = () => workLoop(config); |
24
index.js
const _ = { | ||
isFunction: require('lodash/isFunction'), | ||
noop: require('lodash/noop') | ||
noop: require('lodash/noop'), | ||
}; | ||
@@ -14,7 +14,7 @@ const readline = require('readline'); | ||
validate: () => true, | ||
filter: val => val, | ||
transformer: val => val | ||
filter: (val) => val, | ||
transformer: (val) => val, | ||
}; | ||
const defaultMapStateToValue = state => { | ||
const defaultMapStateToValue = (state) => { | ||
if (!state.value) { | ||
@@ -36,3 +36,3 @@ return state.default; | ||
value: '', | ||
status: 'idle' | ||
status: 'idle', | ||
}; | ||
@@ -50,3 +50,3 @@ | ||
input, | ||
output | ||
output, | ||
}); | ||
@@ -118,3 +118,3 @@ this.screen = new ScreenManager(this.rl); | ||
submit: this.onSubmit, | ||
setState: this.setState | ||
setState: this.setState, | ||
}); | ||
@@ -158,3 +158,3 @@ } | ||
status: 'idle', | ||
error: error || 'You must provide a valid value' | ||
error: error || 'You must provide a valid value', | ||
}); | ||
@@ -201,3 +201,3 @@ } | ||
{ | ||
prefix: this.getPrefix() | ||
prefix: this.getPrefix(), | ||
}, | ||
@@ -211,3 +211,3 @@ state, | ||
filter: undefined, | ||
transformer: undefined | ||
transformer: undefined, | ||
} | ||
@@ -220,4 +220,4 @@ ); | ||
exports.createPrompt = (config, render) => { | ||
const run = initialState => | ||
new Promise(resolve => { | ||
const run = (initialState) => | ||
new Promise((resolve) => { | ||
const prompt = new StateManager(config, initialState, render); | ||
@@ -224,0 +224,0 @@ prompt.execute(resolve); |
@@ -1,13 +0,13 @@ | ||
exports.isUpKey = key => | ||
exports.isUpKey = (key) => | ||
key.name === 'up' || key.name === 'k' || (key.name === 'p' && key.ctrl); | ||
exports.isDownKey = key => | ||
exports.isDownKey = (key) => | ||
key.name === 'down' || key.name === 'j' || (key.name === 'n' && key.ctrl); | ||
exports.isSpaceKey = key => key.name === 'space'; | ||
exports.isSpaceKey = (key) => key.name === 'space'; | ||
exports.isBackspaceKey = key => key.name === 'backspace'; | ||
exports.isBackspaceKey = (key) => key.name === 'backspace'; | ||
exports.isNumberKey = key => '123456789'.includes(key.name); | ||
exports.isNumberKey = (key) => '123456789'.includes(key.name); | ||
exports.isEnterKey = key => key.name === 'enter' || key.name === 'return'; | ||
exports.isEnterKey = (key) => key.name === 'enter' || key.name === 'return'; |
@@ -1,2 +0,2 @@ | ||
exports.getPromptConfig = async options => { | ||
exports.getPromptConfig = async (options) => { | ||
let message = options.message; | ||
@@ -10,4 +10,4 @@ if (typeof options.message === 'function') { | ||
...options, | ||
message: await message | ||
message: await message, | ||
}; | ||
}; |
'use strict'; | ||
const _ = { | ||
flatten: require('lodash/flatten') | ||
flatten: require('lodash/flatten'), | ||
}; | ||
@@ -6,0 +6,0 @@ const chalk = require('chalk'); |
@@ -5,3 +5,3 @@ const chalk = require('chalk'); | ||
exports.usePrefix = isLoading => { | ||
exports.usePrefix = (isLoading) => { | ||
const [tick, setTick] = useState(0); | ||
@@ -8,0 +8,0 @@ |
@@ -9,3 +9,3 @@ const ansiEscapes = require('ansi-escapes'); | ||
exports.left = function(rl, x) { | ||
exports.left = function (rl, x) { | ||
rl.output.write(ansiEscapes.cursorBackward(x)); | ||
@@ -20,3 +20,3 @@ }; | ||
exports.right = function(rl, x) { | ||
exports.right = function (rl, x) { | ||
rl.output.write(ansiEscapes.cursorForward(x)); | ||
@@ -31,3 +31,3 @@ }; | ||
exports.up = function(rl, x) { | ||
exports.up = function (rl, x) { | ||
rl.output.write(ansiEscapes.cursorUp(x)); | ||
@@ -42,3 +42,3 @@ }; | ||
exports.down = function(rl, x) { | ||
exports.down = function (rl, x) { | ||
rl.output.write(ansiEscapes.cursorDown(x)); | ||
@@ -52,4 +52,4 @@ }; | ||
*/ | ||
exports.clearLine = function(rl, len) { | ||
exports.clearLine = function (rl, len) { | ||
rl.output.write(ansiEscapes.eraseLines(len)); | ||
}; |
const _ = { | ||
last: require('lodash/last') | ||
last: require('lodash/last'), | ||
}; | ||
@@ -11,4 +11,4 @@ const cliWidth = require('cli-width'); | ||
const height = content => content.split('\n').length; | ||
const lastLine = content => _.last(content.split('\n')); | ||
const height = (content) => content.split('\n').length; | ||
const lastLine = (content) => _.last(content.split('\n')); | ||
@@ -15,0 +15,0 @@ module.exports = class ScreenManager { |
const _ = { | ||
flatten: require('lodash/flatten') | ||
flatten: require('lodash/flatten'), | ||
}; | ||
@@ -15,3 +15,3 @@ | ||
return _.flatten( | ||
content.split('\n').map(line => { | ||
content.split('\n').map((line) => { | ||
const chunk = line.match(regex); | ||
@@ -18,0 +18,0 @@ // Remove the last match as it's always empty |
{ | ||
"name": "@inquirer/core", | ||
"version": "0.0.10-alpha.0", | ||
"version": "0.0.11-alpha.0", | ||
"description": "Core Inquirer prompt API", | ||
@@ -17,5 +17,5 @@ "main": "index.js", | ||
"ansi-escapes": "^4.2.1", | ||
"chalk": "^3.0.0", | ||
"chalk": "^4.1.0", | ||
"cli-spinners": "^2.2.0", | ||
"cli-width": "^2.2.0", | ||
"cli-width": "^3.0.0", | ||
"lodash": "^4.17.12", | ||
@@ -30,3 +30,3 @@ "mute-stream": "^0.0.8", | ||
}, | ||
"gitHead": "7a699cc7566b4b6bc9a1e8d93490d3f5a01685ef" | ||
"gitHead": "434228aba4908e22063eef37869a427bb605337b" | ||
} |
18
test.js
@@ -5,3 +5,3 @@ const readline = require('readline'); | ||
jest.mock('readline', () => { | ||
const readline = require.requireActual('readline'); | ||
const readline = jest.requireActual('readline'); | ||
const EventEmitter = require('events'); | ||
@@ -19,3 +19,3 @@ const stream = require('stream'); | ||
output: new MuteStream(), | ||
input: new MuteStream() | ||
input: new MuteStream(), | ||
}); | ||
@@ -33,3 +33,3 @@ fakeInstance2.line = ''; | ||
let resolveCb; | ||
const promise = new Promise(resolve => { | ||
const promise = new Promise((resolve) => { | ||
resolveCb = resolve; | ||
@@ -48,3 +48,3 @@ }); | ||
message: 'Loading...', | ||
status: 'loading' | ||
status: 'loading', | ||
}), | ||
@@ -60,3 +60,3 @@ {} | ||
message: 'Loading...', | ||
status: 'loading' | ||
status: 'loading', | ||
}), | ||
@@ -111,3 +111,3 @@ {} | ||
value: 'new value', | ||
status: 'done' | ||
status: 'done', | ||
}), | ||
@@ -170,3 +170,3 @@ {} | ||
message: 'Question:', | ||
error: 'You must provide a valid value' | ||
error: 'You must provide a valid value', | ||
}), | ||
@@ -198,3 +198,3 @@ {} | ||
message: 'Question:', | ||
error: expect.stringMatching('Only numbers allowed') | ||
error: expect.stringMatching('Only numbers allowed'), | ||
}), | ||
@@ -227,3 +227,3 @@ {} | ||
transformer, | ||
filter: () => 'dummy value' | ||
filter: () => 'dummy value', | ||
}); | ||
@@ -230,0 +230,0 @@ expect(render).toHaveBeenCalledTimes(1); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26817
+ Addedchalk@4.1.2(transitive)
+ Addedcli-width@3.0.0(transitive)
- Removedchalk@3.0.0(transitive)
- Removedcli-width@2.2.1(transitive)
Updatedchalk@^4.1.0
Updatedcli-width@^3.0.0