platform-agnostic

Precisely what owns the 'current working directory'?

最后都变了- 提交于 2019-12-19 19:47:12
问题 I'm aware what a working directory (wd) is and it's purpose (for writing software at least). What I don't understand is the ownership of the wd. Furthermore, I want to understand how the answer may vary between operating systems so any clarification on unusual behaviour on a particular OS would be appreciated. So firstly, where does the wd manifest itself? Is it within a process, and all threads created by that process share the same wd? If the wd gets modified by thread 'A', is the change

Node.js - Find home directory in platform agnostic way

 ̄綄美尐妖づ 提交于 2019-11-27 10:24:20
Process.platform returns "win32" for Windows. On Windows a user's home directory might be C:\Users[USERNAME] or C:\Documents and Settings[USERNAME] depending on which version of Windows is being used. On Unix this isn't an issue. As mentioned in a more recent answer , the preferred way is now simply: const homedir = require('os').homedir(); [Original Answer] : Why not use the USERPROFILE environment variable on win32? function getUserHome() { return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']; } os.homedir() was added by this PR and is part of the public 4.0.0 release

Node.js - Find home directory in platform agnostic way

99封情书 提交于 2019-11-26 11:53:38
问题 Process.platform returns \"win32\" for Windows. On Windows a user\'s home directory might be C:\\Users[USERNAME] or C:\\Documents and Settings[USERNAME] depending on which version of Windows is being used. On Unix this isn\'t an issue. 回答1: As mentioned in a more recent answer, the preferred way is now simply: const homedir = require('os').homedir(); [Original Answer] : Why not use the USERPROFILE environment variable on win32? function getUserHome() { return process.env[(process.platform ==