Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
killroy192 committed Jul 17, 2024
1 parent c7b7840 commit 08acfdc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ up-all :; read -s -r -e -p "MASTER_KEY: " && echo $$REPLY > master_key && docker
# cli
list :; npx tsx src/cli/list.ts

encrypt :; export FILE=$(file) && export BACKUP=$(backup) && npx tsx src/cli/encrypt.ts && unset FILE
encrypt :; export FILE=$(file) && export BACKUP=$(backup) && export OUTPUT=$(output) && npx tsx src/cli/encrypt.ts && unset FILE && unset OUTPUT

decrypt :; export FILE=$(file) && export BACKUP=$(backup) && npx tsx src/cli/decrypt.ts && unset FILE
decrypt :; export FILE=$(file) && export BACKUP=$(backup) && export OUTPUT=$(output) && npx tsx src/cli/decrypt.ts && unset FILE && unset OUTPUT

funding :; npx tsx src/cli/funding.ts

Expand Down
3 changes: 2 additions & 1 deletion src/cli/decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { getMasterKey } from "src/libs/shared";
}

const decryptedJson = decryptJson(readFileSync(file, "utf-8"), masterKey);
writeFileSync(file, JSON.stringify(decryptedJson, null, 2));
const output = resolve(".", process.env.OUTPUT as string);
writeFileSync(output, JSON.stringify(decryptedJson, null, 2));

console.log("decrypt script finished");
})();
3 changes: 2 additions & 1 deletion src/cli/encrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { getMasterKey } from "src/libs/shared";
await copyFile(file, resolve(".", "decoded.backup.json"));
}

writeFileSync(file, encrypt(readFileSync(file, "utf-8"), masterKey));
const output = resolve(".", process.env.OUTPUT as string);
writeFileSync(file, encrypt(readFileSync(output, "utf-8"), masterKey));

console.log("encrypt script finished");
})();

0 comments on commit 08acfdc

Please sign in to comment.