-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 🎸 handle environment variable access #105
Conversation
Hello @dancrumb, Firstly, I want to express my appreciation for the high standard of this Pull Request. It is clearly evident that a great deal of meticulous work and thought went into it. Your decision to refactor certain parts of the codebase has also been recognized and is greatly appreciated; this effort will undeniably enhance our project's overall readability. However, I wanted to discuss a particular change you've made. I noticed that the compilation target has been altered in your PR. Could you please help me understand your rationale behind this decision? My concern is that this modification might potentially render Denoify incompatible with older versions of Node.js. We'd certainly want to avoid this, as it may impact users who are yet to upgrade to newer Node.js versions. Thank you in advance for addressing this concern. I'm eager to further understand your thought process. |
Hi @garronej , I changed the target so that I could use My rationale was the assumption that anyone using I would agree that those folks might not want their own code built to this target, but it seemed reasonable to bump the denoify target since that's only ever run in a development environment. On the other hand, I'd be happy to convert this to not use Let me know which part you'd prefer to take :) |
Allright, you convinced me 👍🏻 |
Upon further analysis of the code, I was impressed by the simplicity and efficiency of I hope it's not too much to ask, but would you be open to revising your implementation so that the following unit test succeeds? it("should accurately update dynamic environment variables", async () => {
const sourceCode = `process.env["FOO"];process.env['FOO'];process.env["FO" + "O"];process.env[\`F${"O"}O\`]`;
const expected = `Deno.env.get("FOO");Deno.env.get('FOO');Deno.env.get("FO" + "O");Deno.env.get(\`F${"O"}O\`)`;
const { denoifySingleFile } = denoifySingleFileFactory({
"denoifyImportExportStatement": () => {
tsafeAssert(false);
}
});
const modifiedSourceCode = await denoifySingleFile({
sourceCode,
"dirPath": ""
});
expect(modifiedSourceCode).toBe(expected);
}); I believe that it's fairly standard practice to read environment variables dynamically. |
Agreed! I'll address that test case in my fix for #108 |
I did a little refactoring as well as the changes needed for supporting environment variables.
I'm happy to rollback the reactors if you don't like them; just let me know!
✅ Closes: #103