Commit 5301459f authored by Andrew Price's avatar Andrew Price
Browse files

js-duk: Implement mw.whoami()

It's now defined as a function instead of a string because the username
can change.
parent 2a4ad037
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -465,6 +465,13 @@ static duk_ret_t js_termsize(duk_context *cx)
	return 1; /* Result is at top of stack */
}

/* me = mw.whoami(); */
static duk_ret_t js_whoami(duk_context *cx)
{
	duk_push_string(cx, user->record.name);
	return 1;
}

static duk_ret_t js_bind(duk_context *cx)
{
	const char *bind_name = NULL;
@@ -991,6 +998,7 @@ static void define_api(void)
	define_func("beep", js_beep, 1);
	define_func("input", js_input, 1);
	define_func("termsize", js_termsize, 0);
	define_func("whoami", js_whoami, 0);
	define_store_object("store");

	/* mw object */