Tiddlywiki change build target folder

Hi devs!

I create tiddlywiki project using this method:

npm install -g tiddlywiki
tiddlywiki . --init server
tiddlywiki . --build index

The output file is generated under output folder and by default name as index.html.

I can change output file name using file tiddlywiki.info file as:

"build": {
        "index": [
            "--render",
            "$:/plugins/tiddlywiki/tiddlyweb/save/offline",
            "customfilename.html",
            "text/plain",
            "--output",
            " my-tiddlywiki"
        ],

But --output is not working, also I have tried tiddlywiki . --build index --output .
which is still not working,

How can is change output dir e.g. . (root dir)

Okey! I have find-out the solution:

in tiddlywiki.info, I change the path as:

"build": {
        "index": [
            "--render",
            "$:/plugins/tiddlywiki/tiddlyweb/save/offline",
            "../customfilename.html",
            "text/plain"
        ]
}

e.g. path before file name.

You could have moved the --output command into the front, before --render – BUT if output is set once, it is valid for all consecutive commands that follow.

So it’s better to create a second section eg: myindex So the tiddlywiki.info would look like this:

"build": {
        "index": [
            "--render",
            "$:/plugins/tiddlywiki/tiddlyweb/save/offline",
            "../customfilename.html",
            "text/plain"
        ],
       "myindex": [
            "--output", " my-tiddlywiki",
            "--render",
            "$:/plugins/tiddlywiki/tiddlyweb/save/offline",
            "../customfilename.html",
            "text/plain"
        ]
}

I did not test the above code. I usually have a closer look at: https://github.com/Jermolene/TiddlyWiki5/blob/ba5bfd1ad07b8afc54a329f942a93142b39a673c/editions/tw5.com/tiddlywiki.info#L49 and adjust as needed.

To expand on this a little the tiddlywiki command looks like this:

tiddlywiki <wiki-path> \
  --command1 [<params>] \
  --command2 [<params>] \
  --command3 [<params>] \
  ...

and the commands run sequentially. So when you do the equivalent of

tiddlywiki . --render $:/plugins/tiddlywiki/tiddlyweb/save/offline customfilename.html text/plain \
             --output my-tiddlywiki

you’re telling TW to run the render command and when it’s complete run the output command. This is an elegant mechanism but somewhat different from conventional UNIX-style flags; it can take some getting used to.

Here the output command sets the value to be used by subsequent commands, so when you put it first, the render command will use the value it sets.


BTW, not all combinations will work. I find that I can’t do this:

tiddlywiki . --init server --listen port=7901

I’m pretty sure that’s because while --init server saves the tiddlywiki.info file, the OS probably hasn’t finished saving that before the --listen command starts.