update
This commit is contained in:
15
package/node_modules/read/LICENSE
generated
vendored
Normal file
15
package/node_modules/read/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
3
package/node_modules/read/dist/commonjs/package.json
generated
vendored
Normal file
3
package/node_modules/read/dist/commonjs/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
95
package/node_modules/read/dist/commonjs/read.js
generated
vendored
Normal file
95
package/node_modules/read/dist/commonjs/read.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.read = void 0;
|
||||
const mute_stream_1 = __importDefault(require("mute-stream"));
|
||||
const readline_1 = require("readline");
|
||||
async function read({ default: def, input = process.stdin, output = process.stdout, completer, prompt = '', silent, timeout, edit, terminal, replace, }) {
|
||||
if (typeof def !== 'undefined' &&
|
||||
typeof def !== 'string' &&
|
||||
typeof def !== 'number') {
|
||||
throw new Error('default value must be string or number');
|
||||
}
|
||||
let editDef = false;
|
||||
const defString = def?.toString();
|
||||
prompt = prompt.trim() + ' ';
|
||||
terminal = !!(terminal || output.isTTY);
|
||||
if (defString) {
|
||||
if (silent) {
|
||||
prompt += '(<default hidden>) ';
|
||||
// TODO: add tests for edit
|
||||
/* c8 ignore start */
|
||||
}
|
||||
else if (edit) {
|
||||
editDef = true;
|
||||
/* c8 ignore stop */
|
||||
}
|
||||
else {
|
||||
prompt += '(' + defString + ') ';
|
||||
}
|
||||
}
|
||||
const m = new mute_stream_1.default({ replace, prompt });
|
||||
m.pipe(output, { end: false });
|
||||
output = m;
|
||||
return new Promise((resolve, reject) => {
|
||||
const rl = (0, readline_1.createInterface)({ input, output, terminal, completer });
|
||||
// TODO: add tests for timeout
|
||||
/* c8 ignore start */
|
||||
const timer = timeout && setTimeout(() => onError(new Error('timed out')), timeout);
|
||||
/* c8 ignore stop */
|
||||
m.unmute();
|
||||
rl.setPrompt(prompt);
|
||||
rl.prompt();
|
||||
if (silent) {
|
||||
m.mute();
|
||||
// TODO: add tests for edit + default
|
||||
/* c8 ignore start */
|
||||
}
|
||||
else if (editDef && defString) {
|
||||
const rlEdit = rl;
|
||||
rlEdit.line = defString;
|
||||
rlEdit.cursor = defString.length;
|
||||
rlEdit._refreshLine();
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
const done = () => {
|
||||
rl.close();
|
||||
clearTimeout(timer);
|
||||
m.mute();
|
||||
m.end();
|
||||
};
|
||||
// TODO: add tests for rejecting
|
||||
/* c8 ignore start */
|
||||
const onError = (er) => {
|
||||
done();
|
||||
reject(er);
|
||||
};
|
||||
/* c8 ignore stop */
|
||||
rl.on('error', onError);
|
||||
rl.on('line', line => {
|
||||
// TODO: add tests for silent
|
||||
/* c8 ignore start */
|
||||
if (silent && terminal) {
|
||||
m.unmute();
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
done();
|
||||
// TODO: add tests for default
|
||||
/* c8 ignore start */
|
||||
// truncate the \n at the end.
|
||||
return resolve(line.replace(/\r?\n?$/, '') || defString || '');
|
||||
/* c8 ignore stop */
|
||||
});
|
||||
// TODO: add tests for sigint
|
||||
/* c8 ignore start */
|
||||
rl.on('SIGINT', () => {
|
||||
rl.close();
|
||||
onError(new Error('canceled'));
|
||||
});
|
||||
/* c8 ignore stop */
|
||||
});
|
||||
}
|
||||
exports.read = read;
|
||||
//# sourceMappingURL=read.js.map
|
3
package/node_modules/read/dist/esm/package.json
generated
vendored
Normal file
3
package/node_modules/read/dist/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
88
package/node_modules/read/dist/esm/read.js
generated
vendored
Normal file
88
package/node_modules/read/dist/esm/read.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import Mute from 'mute-stream';
|
||||
import { createInterface } from 'readline';
|
||||
export async function read({ default: def, input = process.stdin, output = process.stdout, completer, prompt = '', silent, timeout, edit, terminal, replace, }) {
|
||||
if (typeof def !== 'undefined' &&
|
||||
typeof def !== 'string' &&
|
||||
typeof def !== 'number') {
|
||||
throw new Error('default value must be string or number');
|
||||
}
|
||||
let editDef = false;
|
||||
const defString = def?.toString();
|
||||
prompt = prompt.trim() + ' ';
|
||||
terminal = !!(terminal || output.isTTY);
|
||||
if (defString) {
|
||||
if (silent) {
|
||||
prompt += '(<default hidden>) ';
|
||||
// TODO: add tests for edit
|
||||
/* c8 ignore start */
|
||||
}
|
||||
else if (edit) {
|
||||
editDef = true;
|
||||
/* c8 ignore stop */
|
||||
}
|
||||
else {
|
||||
prompt += '(' + defString + ') ';
|
||||
}
|
||||
}
|
||||
const m = new Mute({ replace, prompt });
|
||||
m.pipe(output, { end: false });
|
||||
output = m;
|
||||
return new Promise((resolve, reject) => {
|
||||
const rl = createInterface({ input, output, terminal, completer });
|
||||
// TODO: add tests for timeout
|
||||
/* c8 ignore start */
|
||||
const timer = timeout && setTimeout(() => onError(new Error('timed out')), timeout);
|
||||
/* c8 ignore stop */
|
||||
m.unmute();
|
||||
rl.setPrompt(prompt);
|
||||
rl.prompt();
|
||||
if (silent) {
|
||||
m.mute();
|
||||
// TODO: add tests for edit + default
|
||||
/* c8 ignore start */
|
||||
}
|
||||
else if (editDef && defString) {
|
||||
const rlEdit = rl;
|
||||
rlEdit.line = defString;
|
||||
rlEdit.cursor = defString.length;
|
||||
rlEdit._refreshLine();
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
const done = () => {
|
||||
rl.close();
|
||||
clearTimeout(timer);
|
||||
m.mute();
|
||||
m.end();
|
||||
};
|
||||
// TODO: add tests for rejecting
|
||||
/* c8 ignore start */
|
||||
const onError = (er) => {
|
||||
done();
|
||||
reject(er);
|
||||
};
|
||||
/* c8 ignore stop */
|
||||
rl.on('error', onError);
|
||||
rl.on('line', line => {
|
||||
// TODO: add tests for silent
|
||||
/* c8 ignore start */
|
||||
if (silent && terminal) {
|
||||
m.unmute();
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
done();
|
||||
// TODO: add tests for default
|
||||
/* c8 ignore start */
|
||||
// truncate the \n at the end.
|
||||
return resolve(line.replace(/\r?\n?$/, '') || defString || '');
|
||||
/* c8 ignore stop */
|
||||
});
|
||||
// TODO: add tests for sigint
|
||||
/* c8 ignore start */
|
||||
rl.on('SIGINT', () => {
|
||||
rl.close();
|
||||
onError(new Error('canceled'));
|
||||
});
|
||||
/* c8 ignore stop */
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=read.js.map
|
87
package/node_modules/read/package.json
generated
vendored
Normal file
87
package/node_modules/read/package.json
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"name": "read",
|
||||
"version": "3.0.1",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/esm/read.d.ts",
|
||||
"default": "./dist/esm/read.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/commonjs/read.d.ts",
|
||||
"default": "./dist/commonjs/read.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "module",
|
||||
"tshy": {
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": "./src/read.ts"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"mute-stream": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@npmcli/eslint-config": "^4.0.2",
|
||||
"@npmcli/template-oss": "4.20.0",
|
||||
"@types/mute-stream": "^0.0.4",
|
||||
"@types/tap": "^15.0.11",
|
||||
"@typescript-eslint/parser": "^6.11.0",
|
||||
"c8": "^8.0.1",
|
||||
"eslint-import-resolver-typescript": "^3.6.1",
|
||||
"tap": "^16.3.9",
|
||||
"ts-node": "^10.9.1",
|
||||
"tshy": "^1.8.0",
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
|
||||
},
|
||||
"author": "GitHub Inc.",
|
||||
"description": "read(1) for node programs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/npm/read.git"
|
||||
},
|
||||
"license": "ISC",
|
||||
"scripts": {
|
||||
"prepare": "tshy",
|
||||
"pretest": "npm run prepare",
|
||||
"presnap": "npm run prepare",
|
||||
"test": "c8 tap",
|
||||
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
|
||||
"postlint": "template-oss-check",
|
||||
"template-oss-apply": "template-oss-apply --force",
|
||||
"lintfix": "npm run lint -- --fix",
|
||||
"snap": "c8 tap",
|
||||
"posttest": "npm run lint"
|
||||
},
|
||||
"templateOSS": {
|
||||
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
||||
"version": "4.20.0",
|
||||
"publish": true,
|
||||
"typescript": true,
|
||||
"content": "./scripts/template-oss"
|
||||
},
|
||||
"main": "./dist/commonjs/read.js",
|
||||
"types": "./dist/commonjs/read.d.ts",
|
||||
"tap": {
|
||||
"coverage": false,
|
||||
"node-arg": [
|
||||
"--no-warnings",
|
||||
"--loader",
|
||||
"ts-node/esm"
|
||||
],
|
||||
"ts": false,
|
||||
"nyc-arg": [
|
||||
"--exclude",
|
||||
"tap-snapshots/**"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"dist/"
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user