danday74 / envsub

NPM - envsub is envsubst for Node.js
Other
62 stars 10 forks source link

Provide a synchronous API #3

Open Woodz opened 6 years ago

Woodz commented 6 years ago

Providing an asynchronous API that returns Promises forces an asynchronous approach instead of giving developers the flexibility to use the API in a synchronous or asynchronous way. I propose something like:

var result = envsub_sync(templateFile, outputFile, options);
danday74 commented 6 years ago

I totally agree with you. I discovered sync was the best way to offer a module after developing this. I prob should used file streaming too. O well. I'm very busy at the moment and the changes required would be quite time consuming (mainly because of the changes to the unit tests) so I don't think this will be done anytime soon.

I would be more inclined to put the effort in if this module was massively popular but since its only getting 50 downloads a day I don't see fixing this as a massive need in the JS community.

However, I will leave this open with the intention of getting back to this sometime in the future.

danday74 commented 4 years ago

Now that this module is more popular, I am willing to put the effort in to fix this. However, I only plan to do so if there is more demand.

I get the impression that envsub is largely used as a global install and thus fixing this issue seems less important.

Does anyone else want this fixed? If so let me know and I will crack on with it.

Leaving open for now.

skorunka commented 3 years ago

Me ;)

skorunka commented 3 years ago

Can be achieved by using https://stackoverflow.com/a/54139860/522322

        const _envsub = () => envsub({ templateFile, outputFile, options })
            .then((x) => console.log('done'))
            .catch((err) => console.error('[ERROR]', err.message));

        const sync_envsub = sp(_envsub);
        sync_envsub();