benallfree / gobot

Popular binaries via npm. CLI and API.
22 stars 2 forks source link

pocketbase --dir does not work #5

Closed VictorioBerra closed 8 months ago

VictorioBerra commented 8 months ago
import { gobot } from "gobot";
import { fileURLToPath } from "url";
import { dirname, join } from "path";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const bot = await gobot(`pocketbase/pocketbase`);
bot.run([`-v`]);
bot.run([`serve --dir ${join(__dirname, "/pb_data")}`]);
pocketbase.exe version 0.22.7
Error: unknown command "serve --dir 'C:\\Users\\toryb\\source\\repos\\Failreactor-Pocketbase - JS\\pb_data'" for "pocketbase.exe"
Run 'pocketbase.exe --help' for usage.

I have my index.js and my /pb_data in the same folder, I think most people will do this. Otherwise, wouldn't upgrading the PB version via GotBot create a new pb_data?

Anways, Gobot is not correctly passing the args to pocketbase it seems. As running the command manually works fine:

C:\Users\toryb\AppData\Local\gobot-nodejs\Cache\pocketbase\pocketbase\archives\0.22.7\x64\win32\pocketbase.exe serve --dir 'C:\\Users\\toryb\\source\\repos\\Failreactor-Pocketbase - JS\\pb_data'

VictorioBerra commented 8 months ago

Does not work either (using --dir=X):

bot.run([`serve --dir=${join(__dirname, "pb_data")}`]);
benallfree commented 8 months ago

Try each arg as a separate array element.

VictorioBerra commented 8 months ago

Worked. Thanks!

Final code:

import { gobot } from "gobot";
import { fileURLToPath } from "url";
import { dirname, join } from "path";

// ES Module way to re-create __dirname :/
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const bot = await gobot(`pocketbase/pocketbase`);
bot.run([`-v`]);
bot.run([`serve`, `--dir=${join(__dirname, "pb_data")}`]);