diff --git a/Makefile b/Makefile index 623fda7..786351e 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/src/cli/decrypt.ts b/src/cli/decrypt.ts index 298294e..acf8286 100644 --- a/src/cli/decrypt.ts +++ b/src/cli/decrypt.ts @@ -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"); })(); diff --git a/src/cli/encrypt.ts b/src/cli/encrypt.ts index 8c64814..77a721c 100644 --- a/src/cli/encrypt.ts +++ b/src/cli/encrypt.ts @@ -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"); })();