Force a certain source file to always be recompiled

11 views
Skip to first unread message

Pito Salas

unread,
Aug 15, 2021, 11:22:09 AM8/15/21
to na...@googlegroups.com
Hi all,

This might be a unique requirement. Because I have a pretty complicated app built on top of Nanoc I would like to say that a particular source file, say ./content/toc.md.erb is always recompiled whenever any other file is being recompiled. So file x changes, nano compile sees that x changed, and recompiles ./content/toc.md.erb as well as x.

Is that possible? I tried some tricks with guard file and that didn’t work. Then I tried nanoc compile -w but that didn’t work because part of my content is in a symlinked directory and it seems that compile -w doesn’t watch the symlink directory as well.

Ideas?

Pito Salas
Faculty, Computer Science
Brandeis University

Dave Everitt

unread,
Aug 25, 2021, 9:18:13 AM8/25/21
to nanoc

The first thing that came to mind would be to set up a bash alias (e.g. `compileall` that runs `touch toc.md.erb; nanoc compile`, if just changing the date and not the contents of a file will trigger Nanoc to recompile that file. If that doesn't do it:

Set up `compileall` like before as an alias, but use find and mv to change the filename to a unique timestamp with seconds before the `nanoc complile` command, which would make nanoc recompile:

find ./ -name ./toc-*.erb -exec mv {} ./"toc-$(date +"%F-%H-%M-%S").erb" \;

"./" can be replaced with whatever path is needed

A test:

Filename before: toc-2021-08-25-14-09-23.erb
Filename after: toc-2021-08-25-14-15-35.erb

If neither approach appeals, perhaps add a commented-out version number or date at the top of "toc.md.erb" that you change with awk, then run as an alias as before (sorry, no examples for this one!)

Pito Salas

unread,
Aug 25, 2021, 5:46:10 PM8/25/21
to na...@googlegroups.com
Good ideas Dave. I was looking through the `Rules` file options but didn't see anything there. Actually I am using `Guard` myself if you are familiar with it. I might try your idea with Guard. Thanks again!

Pito Salas
Faculty, Computer Science
Brandeis University

> --
> You received this message because you are subscribed to the Google Groups "nanoc" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nanoc+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/nanoc/e3e3f300-62cf-4444-82de-9b21ecfdbe9cn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages