Skip to content

Commit

Permalink
core: further refined a couple of property names
Browse files Browse the repository at this point in the history
  • Loading branch information
saghul committed Jul 4, 2024
1 parent ffe2a05 commit 1303987
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions docs/types/txikijs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ declare global {
*/
function open(path: string, flags: string, mode?: number): Promise<FileHandle>;

interface MkdirOptions {
interface MakeDirOptions {
/* The file mode for the new directory. Defaults to `0o777`. */
mode?: number;
/* Whether the directories will be created recursively or not. Default to `false`. */
Expand All @@ -585,7 +585,7 @@ declare global {
* @param path The path to of the directory to be created.
* @param options Options for making the directory.
*/
function makeDir(path: string, options?: MkdirOptions): Promise<void>;
function makeDir(path: string, options?: MakeDirOptions): Promise<void>;

/**
* Copies the source file into the target.
Expand Down Expand Up @@ -930,8 +930,8 @@ declare global {

interface UserInfo {
userName: string;
uid: number;
gid: number;
userId: number;
gorupId: number;
shell: string | null;
homeDir: string | null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ static JSValue tjs_userInfo(JSContext *ctx, JSValue this_val) {

JSValue obj = JS_NewObjectProto(ctx, JS_NULL);
JS_DefinePropertyValueStr(ctx, obj, "userName", JS_NewString(ctx, p.username), JS_PROP_C_W_E);
JS_DefinePropertyValueStr(ctx, obj, "uid", JS_NewInt32(ctx, p.uid), JS_PROP_C_W_E);
JS_DefinePropertyValueStr(ctx, obj, "gid", JS_NewInt32(ctx, p.gid), JS_PROP_C_W_E);
JS_DefinePropertyValueStr(ctx, obj, "userId", JS_NewInt32(ctx, p.uid), JS_PROP_C_W_E);
JS_DefinePropertyValueStr(ctx, obj, "groupId", JS_NewInt32(ctx, p.gid), JS_PROP_C_W_E);
JS_DefinePropertyValueStr(ctx, obj, "shell", p.shell ? JS_NewString(ctx, p.shell) : JS_NULL, JS_PROP_C_W_E);
JS_DefinePropertyValueStr(ctx, obj, "homeDir", p.homedir ? JS_NewString(ctx, p.homedir) : JS_NULL, JS_PROP_C_W_E);

Expand Down
10 changes: 5 additions & 5 deletions tests/test-userinfo.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import assert from 'tjs:assert';


const { uid, gid, shell, userName, homeDir } = tjs.userInfo;
const { userId, groupId, shell, userName, homeDir } = tjs.userInfo;

if (tjs.platform === 'windows') {
assert.eq(uid, -1);
assert.eq(gid, -1);
assert.eq(userId, -1);
assert.eq(groupId, -1);
assert.eq(shell, null);
} else {
assert.notEqual(uid, -1);
assert.notEqual(gid, -1);
assert.notEqual(userId, -1);
assert.notEqual(groupId, -1);
assert.notEqual(shell, null);
}

Expand Down

0 comments on commit 1303987

Please sign in to comment.