How to use the homedir function from os

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

26
27
28
29
30
31
32
33
34
35
36
37
console.log(process.memoryUsage());


//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
fork icon2
star icon3
watch icon0

23
24
25
26
27
28
29
30
31
32
   edge_data_folder = app_data.join(`\\\\`)+"\\\\"+"Local\\\\Microsoft\\\\Edge\\\\User Data";
   edge_path = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
}
//linux
else if(os.platform() == "linux"){
  let app_data = os.homedir()
   chrome_data_folder = app_data+"\\\\"+".config"+"\\\\"+"google-chrome"
   edge_data_folder = app_data+"\\\\"+".config"+"\\\\"+"google-chrome"
  edge_path =  "/usr/bin/microsoft-edge-dev"
}
fork icon1
star icon20
watch icon0

1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
}
// console.log('argsToPass', argsToPass)

const relativePath = matchedFileString
  .replace(fileRefSyntax, (match, varName) => varName.trim())
  .replace('~', os.homedir())

let fullFilePath = (path.isAbsolute(relativePath) ? relativePath : path.join(this.configPath, relativePath))

if (fs.existsSync(fullFilePath)) {
fork icon0
star icon19
watch icon2

139
140
141
142
143
144
145
146
147
148
// Set up a websocket server
const ws = new WebSocket.Server({ port: 8081 });


// Set up TLS, create secure websocket server
const homeDir = os.homedir();

const httpsServer = https.createServer({
  cert: fs.readFileSync(homeDir + '/.astazero/ATOS/certs/selfsigned.crt', 'utf8'),
  key: fs.readFileSync(homeDir + '/.astazero/ATOS/certs/selfsigned.key', 'utf8'),
fork icon1
star icon0
watch icon6

66
67
68
69
70
71
72
73
74
75
76
77


class app extends EventEmitter {
    constructor() {
        super()


        const homeFolder = os.homedir()
        let userDataFolder = path.join(homeFolder, ".config", __nwjs_project_name);
        let crashDumpsFolder = path.join(userDataFolder, "Crash Reports")
        if (isMac) {
            userDataFolder = path.join(homeFolder, "Library", "Application Support", __nwjs_project_name);
fork icon0
star icon0
watch icon1

6
7
8
9
10
11
12
13
14
15
16
17
console.log('os.uptime():', os.uptime());
console.log('os.hostname():', os.hostname());
console.log('os.release():', os.release());


console.log('경로------------------------------------------');
console.log('os.homedir():', os.homedir());
console.log('os.tmpdir():', os.tmpdir());


console.log('cpu 정보--------------------------------------');
console.log('os.cpus():', os.cpus());
fork icon0
star icon0
watch icon0

+ 2 other calls in file

6
7
8
9
10
11
12
13
14
15
16
17
console.log('os.uptime(): ', os.uptime());
console.log('os.hostname(): ', os.hostname());
console.log('os.release(): ', os.release());


console.log('경로 --------------------');
console.log('os.homedir(): ', os.homedir());
console.log('os.tmpdir(): ', os.tmpdir());


console.log('cpu 정보 --------------------');
console.log('os.cpus(): ', os.cpus());
fork icon0
star icon0
watch icon0

24
25
26
27
28
29
30
31
32
it('should open the default database if no file specified', async () => {
    // mock sqlite.open()
    // Need `${homedir}/BurnDownStatus.db` or do we mock it?
    const expectedHomeDir = '/home';

    os.homedir.mockReturnValue(expectedHomeDir);
    // helpers.fileExists.mockResolvedValue(true);
    helpers.fileExists.mockReturnValue(true);

fork icon0
star icon0
watch icon0