New:Socket for Asana Is Now Available.Learn more
Get Started

@inquirer/editor

Package Overview
Dependencies
Maintainers
2
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inquirer/editor - npm Package Compare versions

Comparing version
5.0.10
to
5.1.0
+3
-2
dist/index.d.ts

@@ -1,2 +0,2 @@

import { type IFileOptions } from '@inquirer/external-editor';
import { type FileOptions } from '@inquirer/external-editor';
import { type Theme } from '@inquirer/core';

@@ -7,2 +7,3 @@ import type { PartialDeep } from '@inquirer/type';

style: {
loadingMessage: () => string;
waitingMessage: (enterKey: string) => string;

@@ -17,3 +18,3 @@ };

validate?: (value: string) => boolean | string | Promise<string | boolean>;
file?: IFileOptions;
file?: FileOptions;
theme?: PartialDeep<Theme<EditorTheme>>;

@@ -20,0 +21,0 @@ };

+26
-27

@@ -6,2 +6,3 @@ import { editAsync } from '@inquirer/external-editor';

style: {
loadingMessage: () => 'Validating...',
waitingMessage: (enterKey) => `Press ${enterKey} to launch your preferred editor.`,

@@ -17,38 +18,33 @@ },

const prefix = usePrefix({ status, theme });
function startEditor(rl) {
async function startEditor(rl) {
rl.pause();
const editCallback = async (error, answer) => {
try {
const answer = await editAsync(value, { postfix, ...fileProps });
rl.resume();
if (error) {
setError(error.toString());
setStatus('loading');
const isValid = await validate(answer);
if (isValid === true) {
setError(undefined);
setStatus('done');
done(answer);
}
else {
setStatus('loading');
const finalAnswer = answer ?? '';
const isValid = await validate(finalAnswer);
if (isValid === true) {
setError(undefined);
setStatus('done');
done(finalAnswer);
if (theme.validationFailureMode === 'clear') {
setValue(config.default);
}
else {
if (theme.validationFailureMode === 'clear') {
setValue(config.default);
}
else {
setValue(finalAnswer);
}
setError(isValid || 'You must provide a valid value');
setStatus('idle');
setValue(answer);
}
setError(isValid || 'You must provide a valid value');
setStatus('idle');
}
};
editAsync(value, (error, answer) => void editCallback(error, answer), {
postfix,
...fileProps,
});
}
catch (error) {
rl.resume();
setError(String(error));
}
}
useEffect((rl) => {
if (!waitForUserInput) {
startEditor(rl);
void startEditor(rl);
}

@@ -62,3 +58,3 @@ }, []);

if (isEnterKey(key)) {
startEditor(rl);
void startEditor(rl);
}

@@ -68,3 +64,6 @@ });

let helpTip = '';
if (status === 'idle') {
if (status === 'loading') {
helpTip = theme.style.help(theme.style.loadingMessage());
}
else if (status === 'idle') {
const enterKey = theme.style.key('enter');

@@ -71,0 +70,0 @@ helpTip = theme.style.help(theme.style.waitingMessage(enterKey));

{
"name": "@inquirer/editor",
"version": "5.0.10",
"version": "5.1.0",
"description": "Inquirer multiline editor prompt",

@@ -70,8 +70,8 @@ "keywords": [

"dependencies": {
"@inquirer/core": "^11.1.7",
"@inquirer/external-editor": "^2.0.4",
"@inquirer/type": "^4.0.4"
"@inquirer/core": "^11.1.8",
"@inquirer/external-editor": "^3.0.0",
"@inquirer/type": "^4.0.5"
},
"devDependencies": {
"typescript": "^5.9.3"
"typescript": "^6.0.2"
},

@@ -91,3 +91,3 @@ "peerDependencies": {

"types": "./dist/index.d.ts",
"gitHead": "b218fcc4afe888a58957aa78c9a032f9bd2d60cb"
"gitHead": "e68fe01d65359e083581c48c4a18cd8f97d88842"
}