mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 20:20:49 +00:00
Remove @inquirer/prompts, update eslint.
This commit is contained in:
parent
5658eb04af
commit
f163101200
4 changed files with 145 additions and 1229 deletions
|
|
@ -28,7 +28,6 @@
|
|||
"license": "AGPL-3.0-or-later",
|
||||
"description": "The Aikido Safe Chain wraps around the [npm cli](https://github.com/npm/cli), [npx](https://github.com/npm/cli/blob/latest/docs/content/commands/npx.md), [yarn](https://yarnpkg.com/), [pnpm](https://pnpm.io/), and [pnpx](https://pnpm.io/cli/dlx) to provide extra checks before installing new packages. This tool will detect when a package contains malware and prompt you to exit, preventing npm, npx, yarn, pnpm, or pnpx from downloading or running the malware.",
|
||||
"dependencies": {
|
||||
"@inquirer/prompts": "^7.4.1",
|
||||
"abbrev": "^3.0.1",
|
||||
"chalk": "^5.4.1",
|
||||
"npm-registry-fetch": "^18.0.2",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import chalk from "chalk";
|
||||
import ora from "ora";
|
||||
import { confirm as inquirerConfirm } from "@inquirer/prompts";
|
||||
import { createInterface } from "readline";
|
||||
import { isCi } from "./environment.js";
|
||||
|
||||
function emptyLine() {
|
||||
|
|
@ -61,12 +61,29 @@ function startProcess(message) {
|
|||
async function confirm(config) {
|
||||
if (isCi()) {
|
||||
return Promise.resolve(config.default);
|
||||
} else {
|
||||
return inquirerConfirm({
|
||||
message: config.message,
|
||||
default: config.default,
|
||||
});
|
||||
}
|
||||
|
||||
const rl = createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
});
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const defaultText = config.default ? " (Y/n)" : " (y/N)";
|
||||
rl.question(`${config.message}${defaultText} `, (answer) => {
|
||||
rl.close();
|
||||
|
||||
const normalizedAnswer = answer.trim().toLowerCase();
|
||||
|
||||
if (normalizedAnswer === "y" || normalizedAnswer === "yes") {
|
||||
resolve(true);
|
||||
} else if (normalizedAnswer === "n" || normalizedAnswer === "no") {
|
||||
resolve(false);
|
||||
} else {
|
||||
resolve(config.default);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export const ui = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue