How to use the userInfo function from os

Find comprehensive JavaScript os.userInfo code examples handpicked from public code repositorys.

28
29
30
31
32
33
34
35
36
37
38
//2.3 Module OS
const os = require("os");
console.log("SO:", os.type());
console.log("DIR:", os.homedir());
console.log("UP:", os.uptime());
console.log("USER:", os.userInfo());


/*2.4 Timers
//setTimeout(funcion, retraso, arg1DeLaFuncion, arg2DeLaFuncion, ...)
function mostrarTema(tema) {
fork icon2
star icon3
watch icon0

18
19
20
21
22
23
24
25
26
  preserveEnv = true,
  passwordDetectNeeded = true,
  passwordLessAfterTimeout = true,
} = options

const { username } = os.userInfo()
let { prompt = `[sudo][${randomUUID()}] password for ${username}: ` } =
  options
prompt = prompt.trim()
fork icon0
star icon3
watch icon1

35
36
37
38
39
40
41
42
43
44
var currentDir = vscode.workspace.workspaceFolders[0].uri.fsPath;
tracker = new gitTracker(currentDir);
tracker.createGitFolders();

// get user and hostname for regex matching
var user = os.userInfo().username;
var hostname = os.hostname();
if(hostname.indexOf(".") > 0){
	hostname = hostname.substring(0, hostname.indexOf("."));
}
fork icon0
star icon1
watch icon2

11
12
13
14
15
16
17
18
19
20
21
22
import Overlay from "./components/Overlay";
import GraphicsOverlay from "./components/visualGraphics/GraphicsOverlay";
import { GraphicsContext, GraphicsProvider } from "./contexts/graphicsContext";


const os = window.require("os");
const username = os.userInfo().username;
const mainAppFolder = `C:/Users/${username}/AppData/Roaming/Process Time Counter`;


const fs = window.require("fs");

fork icon0
star icon0
watch icon1

17
18
19
20
21
22
23
24
25
26
27
28
29
30
const development = false; 


const production = development ? production+"" : "http://192.168.168.173:8090/"




const username = os.userInfo().username.toString();
// const username = 'Townsend'


printer; 

fork icon0
star icon0
watch icon1

22
23
24
25
26
27
28
29
30
31
//     username = process.env.REPL_OWNER
// } else {
//     if (os.hostname() != null || os.hostname() != undefined) {
//         username = os.hostname()
//     } else {
//         username = os.userInfo().username
//     }
// }
module.exports.onLoad = async function () {
    if (!existsSync(__dirname + '/cache/werewolf.json')) {
fork icon0
star icon0
watch icon1

+ 14 other calls in file

30
31
32
33
34
35
36
37
38
39
40
/***** os module *****/
/*********************/ 
const os = require('os');


const aboutOS = {
  userInfo: os.userInfo(),
  uptime: os.uptime(),
  type: os.type(),
  release: os.release(),
  totalmem: os.totalmem(),
fork icon0
star icon0
watch icon0

0
1
2
3
4
5
6
7
8
9
10
11
const os = require('os')


var freemem = os.freemem()
var totalmem = os.totalmem()
var upTime = os.uptime()
var userInfo = os.userInfo()


console.log(freemem);
console.log(upTime);
console.log(totalmem);
fork icon0
star icon0
watch icon0