Last active
January 21, 2019 13:27
-
-
Save hkjels/6c88840f00ab5715fbb00faae4fda0d7 to your computer and use it in GitHub Desktop.
Hook is run, code is executed, but the tangled files have the original content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun svg2code/transpileES5 () | |
"Transpiles the current javascript-mode buffer from ES2015 to ES5" | |
(when (and (string-match ".js$" (buffer-file-name)) | |
(not (string-match "exports.*" (buffer-file-name)))) | |
(shell-command-on-region | |
(point-min) (point-max) | |
"babel --no-babelrc --compact false --presets env" | |
(current-buffer) | |
t | |
"*Babel Error Buffer*" | |
t))) | |
(defun svg2code/run-before-save-hook () | |
(run-hooks 'before-save-hook) | |
(save-buffer)) | |
(add-hook 'js-mode-hook (lambda () (add-hook 'before-save-hook 'svg2code/transpileES5))) | |
(add-hook 'org-babel-post-tangle-hook 'svg2code/run-before-save-hook) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated with a working version