How to start nodejs server from custom path?

26 views
Skip to first unread message

LinOnetwo

unread,
Jan 29, 2020, 5:15:20 AM1/29/20
to TiddlyWiki
I'd like to start server from %appData%/omnitiddly/tiddlywiki , but there seem being no param in cli to do so, it can only start relative to PWD.

I'm going to start tiddlywiki from electron app, so I'm going to do something like this:

const $tw = require('tiddlywiki/boot/boot.js').TiddlyWiki();

// Pass the command line arguments to the boot kernel
$tw.boot.argv = ['listen', '-path %appData%/omnitiddly/tiddlywiki'];

// Boot the TW5 app
$tw.boot.boot();
Can I do so?

LinOnetwo

unread,
Jan 29, 2020, 5:17:00 AM1/29/20
to TiddlyWiki
Oh I know the answer, just add path to first argument:

// If the first command line argument doesn't start with `--` then we
   // interpret it as the path to the wiki folder, which will otherwise default
   // to the current folder
   if($tw.boot.argv[0] && $tw.boot.argv[0].indexOf("--") !== 0) {
     $tw.boot.wikiPath = $tw.boot.argv[0];
     $tw.boot.argv = $tw.boot.argv.slice(1);
   } else {
     $tw.boot.wikiPath = process.cwd();
   }



在 2020年1月29日星期三 UTC+8下午6:15:20,LinOnetwo写道:
Reply all
Reply to author
Forward
0 new messages