Skip to content

Commit

Permalink
Bugfix: encrypt one by one
Browse files Browse the repository at this point in the history
  • Loading branch information
HADMARINE committed Sep 6, 2023
1 parent a182e11 commit 45316a3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quickcert",
"version": "1.2.0",
"version": "1.2.1",
"description": "Manages Certificates, private keys as quick as light with cli intergrated!",
"main": "./dist/index.js",
"bin": "./dist/cli/index.js",
Expand Down
50 changes: 26 additions & 24 deletions src/cli/encrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,35 @@ export default async function encrypt(args: Record<string, any>) {
const privkey = await u.keyResolver(args.key, args.keyfile);
const locs = args.filePath as string[];

locs.forEach(async (loc) => {
if (Object.keys(config).indexOf(loc) !== -1) {
console.log(`${chalk.cyan(`!`)} File already exists.`);

const response = await prompts({
type: 'confirm',
name: 'value',
message: 'Do you want to overwrite?',
});

if (response.value) {
delete config[loc];
} else {
console.log(`${chalk.red(`✘`)} Aborted.`);
return;
await Promise.all(
locs.map(async (loc) => {
if (Object.keys(config).indexOf(loc) !== -1) {
console.log(`${chalk.cyan(`!`)} File already exists.`);

const response = await prompts({
type: 'confirm',
name: 'value',
message: 'Do you want to overwrite?',
});

if (response.value) {
delete config[loc];
} else {
console.log(`${chalk.red(`✘`)} Aborted.`);
return;
}
}
}

try {
const file = fs.readFileSync(loc).toString();
config[loc] = u.encrypt.encrypt(file, privkey);
} catch (e) {
throw e;
}
try {
const file = fs.readFileSync(loc).toString();
config[loc] = u.encrypt.encrypt(file, privkey);
} catch (e) {
throw e;
}

await u.appendPreciseStringOnFileIfExists('.gitignore', loc);
});
await u.appendPreciseStringOnFileIfExists('.gitignore', loc);
}),
);

u.config.set(args.config, config);

Expand Down

0 comments on commit 45316a3

Please sign in to comment.