emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Babel zip after exporting file
@ 2023-03-16 22:39 suarezmiguelc
  2023-03-17 12:41 ` Max Nikulin
  0 siblings, 1 reply; 2+ messages in thread
From: suarezmiguelc @ 2023-03-16 22:39 UTC (permalink / raw)
  To: emacs-orgmode

Hello Emacs org-mode community, I’m trying this example:

** index.js
:PROPERTIES:
:header-args: :tangle index.js :post-tangle (shell-command-to-string "zip index.js.zip index.js && rm index.js")
:END:

First endpoint example:

#+begin_src js
exports.handler = async (event, context) => {
  console.log('Received event:', JSON.stringify(event, null, 2));
  return {
    statusCode: 200,
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      message: 'Hello, world!'
    })
  };
};
#+end_src

What I want is to:
1. Tangle the index.js file
2. Zip it as index.js.zip
3. Delete the raw code index.js

The thing is that, the command inserted in :post-tangle is executed before the creation of the file, so it only works if the file already exists, so:
- First run, file doesn’t exist, only index.js is generated.
- Second run, zip file appears, index.js is intact since the rm index.js command ran but then index.js was generated again.

How should I debug this?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Babel zip after exporting file
  2023-03-16 22:39 Babel zip after exporting file suarezmiguelc
@ 2023-03-17 12:41 ` Max Nikulin
  0 siblings, 0 replies; 2+ messages in thread
From: Max Nikulin @ 2023-03-17 12:41 UTC (permalink / raw)
  To: suarezmiguelc, emacs-orgmode

On 17/03/2023 05:39, suarezmiguelc wrote:
> :PROPERTIES:
> :header-args: :tangle index.js :post-tangle (shell-command-to-string "zip index.js.zip index.js && rm index.js")
> :END:

There is no such feature as :post-tangle. Try
     M-x org-lint

Generic org-babel code is executed instead to evaluate values of all 
header arguments. It happens *before* processing of a code block.

You may be interested in `org-babel-post-tangle-hook'
(info "(org) Extracting Source Code")
https://orgmode.org/manual/Extracting-Source-Code.html#index-org_002dbabel_002dpost_002dtangle_002dhook



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-17 12:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-16 22:39 Babel zip after exporting file suarezmiguelc
2023-03-17 12:41 ` Max Nikulin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).