-
-
Notifications
You must be signed in to change notification settings - Fork 465
Description
Attempting to run staticrypt via npx and the resulting file is not rendering in-place as I expect it to
What's happening
I enter the command:
npx staticrypt --short ./deploy/encrypted/index.html --password testingI'm just attempting to verify the utility works as expected so the short password is fine for now, however the resulting file ends up being written to disk at ./encrypted/index.html instead of ./deploy/encrypted/index.html and this makes zero sense to me.
Digging into the source code this appears to be an unintended pathname collision with the default --directory value "encrypted" assigned in the parseCommandLineArguments() method in helpers.js
What should be happening
I would expect this utility to work in-place and render the target asset where it was previously defined, meaning any fully qualified filepath I pass is mapped implicitly, and the --directory value is a strict output path override that is only used if I provide a value to it.
Justification
I'm using this to encrypt statically generated files for my website that already exist in my ./deploy folder, so I'm not worried about accidentally overwriting my source file as that is not the desired target.
I can see a need for providing a confirmation prompt to the user that this change will be handled in-place and will overwrite the original source file.
Optionally, to avoid any breaking changes with the existing behavior, it would be great to see a --overwrite flag that tells staticrypt to overwrite the files in-place as I expect, and at least this way it's a more obvious and intentional behavior than expecting the user to know they should provide their own --directory argument.
My setup
StatiCrypt version: 3.4.0
Node version: 21.7.1
OS: Ubuntu Linux 22.04
Sample HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
Testing Staticrypt
</body>
</html>