How to detect .env file changes during a process, instantly? - javascript

I am writing an Electron application. I'm using HTML + CSS + JAVASCRIPT with Electron. As you can see below, I have a form and I keep this form information in an .env file. I start the Electron application, open and fill the form, and then save it to the .env file. Thus, my .env file is changed, but I cannot immediately recognize the changes in my .env file. Therefore, if I open my form again, old information is coming. If I restart my Electron application, this event is fixed. How can i solve this problem? I would appreciate your help, my dear developer friends.
First situation: Before I don't save informations to .env file
Second situation: Saved time view
I'm reopen settings window and last result (It gets old information but .env file changed)
Last situation: As you can see...
I'm try app.relaunch() method on this situation. But nothing affect.

There are a few ways to detect changes to a .env file during a process in real-time:
File System Watcher: You can use the watch command in Linux or the fs.watch method in Node.js to watch for changes to a specific file or directory. This method will trigger a callback function whenever the .env file is modified.
Polling: You can use a setInterval or setTimeout function to periodically check the .env file for changes. This method will trigger a callback function if the .env file has been modified since the last check.
Event-driven: You can use an event-driven approach to detect changes to the .env file. This method will trigger a callback function whenever the .env file is modified.
Use a library: There are several libraries available that can be used to detect changes in the .env file like dotenv-expand, dotenv-webpack and etc.
You should choose the method that best suits your specific use case and programming language.
Please keep in mind that the above methods are general suggestions and you may need to make some adjustments depending on your specific use case.

Related

Using Azure's azcopy tool from within a javascript azure function

My setup is the following: I have 1 storage account with a container and I have another storage account with a different container. What I want to do is have a blob trigger activate whenever someone uploads a file to the first storage account, and have that blob be copied to the second storage account's container. azcopy works well with the command line, but I have not found a way to use it within an azure function. Any help is appreciated, thanks.
For NodeJS, you would just use Child Processes (or a wrapper like execa) to run executables but isn't something I would recommend you do. Also, when running on Azure, you will have to make sure azcopy is present and if you still need to go down this path, Custom Containers would be your best bet.
In the case of Azure Functions if the file just must be copied to a different container, you could just use the Blob Output Binding which would achieve this with almost no code.
For more complex scenarios where the output binding lacks, you could just use the Blob Storage NodeJS SDK directly in your code.

Getters involving external data in Vue.js + Vuex

I am developing a Vue+Vuex based app running on Electron.
I hold a directory path as part of the state, signifying the current working directory for the user. In the app, I have a component in which I want to display all the files in the working directory. However, those change over time (the app / user can delete them, create new files, rename file etc...).
The way I originally structured it was to have a getter, which given the current working directory from the state, would fetch the file list. However, as the working directory didn't change, the getter (which only depends on it) wasn't called again.
I don't want to gold the file list in the state, as I don't want to have to update it + the actual file on the machine for every action taken.
I lathered it right now by having a "refresh" action that deletes and resets the working directory in the state, triggering a call to the getter. However, having to call it whenever I suspect something happened to a file is a little tedious.
What is the recommended solution here?

How to use uncrustify with atom-beautify?

I've been looking at the atom-beautify site and example .jsbeauifyrc, .editorconfig, and uncrustify.cgf files.
I've also reviewed the options for atom-beautify. I know I'm supposed to specify where the config file is located in the atom-beautify settings. I've tried putting a .jsbeautifyrc file, an uncrustify.cfg file, and both files in the same directory I specify in the atom-beautify settings. It doesn't have any effect. The default settings are used. I'd like to make some old C++ code look more uniform for my current project and future projects my group is working on.
Which file am I supposed to use?
What must I include in each file?
Where should this/these file(s) be located?
How do I specify the path?
Are there any other changes I need to make that I'm not aware of?
To sum up, I want to use uncrustify from within the Atom editor (using the atom-beautify package) to make my C++ code look nice.
Make sure uncrustify is installed on your computer, and accessible from CLI
In the settings for atom-beautify, go under the C++ section and type uncrustify.cfg as a Config Path
Place the config file name uncrustify.cfg in the root folder
Try beautifying your code, it should be using your config file now
you have to add PathVariable of uncrustify.exe (From Source AtomBeatify : https://atom.io/packages/atom-beautify ) on your system , when you upload you code to Atom click on ALT+CTRL+B it will beautify you Code .
Download zip On Windows, download the latest version of Uncrustify here: https://sourceforge.net/projects/uncrustify/files/latest/download
Extract zip The program is a standalone exe, so just extract the downloaded uncrustify-...-win32.zip file anywhere. For this example, I'll use C:\Uncrustify. So, the uncrustify.exe would be in that directory.
Add directory to PATH System Environment Variable In Windows 7+: Type Winkey + env - Select "Edit the system environment variables"
On the Advanced tab, click the Environment Variables button at the bottom. In the System variables section at the bottom, click the Path variable, then click the Edit... button.
Click the New button, and type C:\Uncrustify, or the directory that you extracted uncrustify.exe to.
Important: Click OK to close the dialog boxes or your change will not save. Verify
In a CMD window, typing where uncrustify should return the path to the uncrustify.exe.
In my case it shows C:\Uncrustify\uncrustify.exe Close Atom and reopen it. Now you should be able to atom-beautify and it will use Uncrustify to format your selection

How to trigger a restart in Brunch's preCompile hook so it reloads the brunch-config.js file?

I've written a quite complex brunch-config.js configuration file that modifies these arrays at the start:
paths.watched and,
files.javascripts / stylesheets (the joinTo "filename" => /patterns/).
What I'd like to do is to restart Brunch when it detects a particular change.
I've got a specific file (acts like a flag to set focus on a specific watch-folder) that can be moved around, and in doing so I'd like the above arrays to re-populate different data based on the special file relocation.
Regarding brunch's built-in restart mechanism, I'm not sure how far it goes (ie: when it's reinstalling NPM modules, or when the brunch-config.js file itself is modified). But if that causes a full reload of the brunch-config.js - How can I trigger this restart functionality via NodeJS code executed within the configuration file, more specifically in the "preCompile" hook?
Here's how it looks like so far in action:

VS2015: Prevent download of dynamically generated JavaScript reference by "JavaScript Language Service"

Please see the below image.. note the timestamps -- my computer does not like this activity. This problem seems to happen whenever I have any *.js or *.cshtml file open.
I have turned off "Download remote references (e.g. http://) for files in the miscellaneous files project" in JavaScript -> IntelliSense -> General, but the problem continues.
I also tried moving the inclusion of "doorbell.io.js" into a bundle rather than the _Layout.cshtml file, but that didn't work.
How can I prevent VS from downloading this JavaScript reference?
To fix the immediate issue
Remove the offending line from "_references.js". Save. The problem should stop immediately.
/// <reference path="doorbell.io.js" />
Future considerations...
Note that by default references are set to auto-sync. This means that if you ever refresh your sources, such as from nuget or by adding a javascript file manually, the offending file could be added back in. You can disable this functionality by right-clicking inside the file and unselecting Auto-sync JavaScript References
If you decide to disable this feature, you can still manually update them with the Update JavaScript References menu item.
Note that at this point in time there is no easy way to prevent a specific file from re-appearing on this list. You will need to remove it manually every time Visual Studio generates this list on your behalf.
Firebase Auth Does the Same Thing
I had a hard time solving this for my application when I switched from 2013 to 2015.
I'm using firebase/angular and any file that referenced my Auth service caused this loop. What ended up solving it was adding this registry item as a DWORD with a value of 0: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\JavaScriptLanguageService\MaximumScriptLoaderReferencesToLoad
All credit goes to Michael Braude with Firebase from this SO: Here

Categories