envsub icon indicating copy to clipboard operation
envsub copied to clipboard

Provide a synchronous API

Open Woodz opened this issue 6 years ago • 4 comments

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);

Woodz avatar Jan 23 '18 07:01 Woodz

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 avatar Mar 09 '18 09:03 danday74

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.

danday74 avatar Dec 01 '19 08:12 danday74

Me ;)

skorunka avatar Mar 30 '21 15:03 skorunka

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();

skorunka avatar Mar 30 '21 15:03 skorunka