Prevent macro from running without babel-marcos
See original GitHub issueI was wondering, as I am using babel-macros in a project now, if there could be a way added so macros could “catch” it when they are being imported in a normal file.
As it seems now, there isn’t such thing. The this
is unset, if packing with webpack I could check if I am running in node (browser won’t), but I also use this on node. Possible would be to check the arguments, but as the mantra of this repo is, I think explicit is better than implicit 😉
I wonder what the best way is though:
- Setting
this
seemed good, but won’t work with arrow functions - Setting a property to check on the macro function itself:
Feels kinda hacky, but again we are putting macros into javascript, So who cares about hacky 😅 (This one is actually also possible (cleaner?) with Symbols)const macros = require(requirePath) + macros.with_babel_macros macros({ references: referencePathsByImportName, state, babel, })
- Passing a symbol as first argument that can be compared
import babelMacros from 'babel-macros'; export default ({ is_babel_macros, references, state }) => { if (is_babel_macros !== babelMacros.is_babel_macros) { ...
Most likely I am missing an option or some perspective, so I’d like to discuss this 😃
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (11 by maintainers)
Top Results From Across the Web
Stop a Macro from Running in Excel - TeachExcel.com
How to stop a macro from running after it has started. This method uses the keyboard and has nothing to do with the...
Read more >Excel: Preventing auto_open and Workbook_Open events ...
At the same time I sometimes want to prevent Workbook_Open event code or an Auto_Open macro from running. This little article shows you...
Read more >Prevent Users from Running Macros | MrExcel Message Board
As long as the user doesn't know the name of the macro, that will work as far as a basic way to hide...
Read more >Macros from the internet will be blocked by default in Office
Provides guidance for admins about how Office blocks macros in files from the internet.
Read more >Stop Running Macro other than ESC / Command +
it is possible that your code is super busy and does not respond to key presses. · Thanks for the help jsotola, but...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’d be happy to take this on!
Not “recommended” … “required” 🕶