syspath
v1.0.6
Published
System Path Determination (Home and Data Directories)
Downloads
19
Readme
SysPath
System Paths Determination (Home and Data Directories)
Abstract
This is a small Node module for conveniently determining the home and data directories of an application.
Installation
$ npm install syspath
Usage
import syspath from "syspath"
let { homeDir, dataDir } = syspath({ appName: "foo" })
console.log(`homeDir: ${homeDir}, dataDir: ${dataDir}`)
Application Programming Interface
syspath({
appName?: string,
dataDirMode?: number,
dataDirAutoCreate?: boolean,
dataDirAutoRemove?: boolean,
}): {
homeDir: string,
dataDir: string
}
The
appName
is the name of the application. By default this ispath.basename(process.argv[1]).replace(/\.[^.]+$/, "")
.The
dataDirMode
is the numerical filesystem mode used for creating thedataDir
(if still not existing anddataDirAutoCreate
istrue
). The default isparseInt("0755", 8) & ~process.umask()
.The
dataDirAutoCreate
forces the automatic creation of thedataDir
(if still not existing, which is usually the case on the initial usage). By default this istrue
.The
dataDirAutoRemove
forces the automatic removal of thedataDir
if it is still empty at the application termination time. By default this istrue
.The
homeDir
is the resolved path to the home directory of the user the application is executed under. The home directory is usually%USERPROFILE%
on Windows or$HOME
on Mac OS X, Linux and FreeBSD.The
dataDir
is the resolved path to the dedicated data directory for the application. The data directory is usually%APPDATA%/<appName>
on Windows,$HOME/Library/Application Support/<appName>
on Mac OS X and$XDG_CONFIG_HOME/<appName>
or$HOME/.config/<appName>
on Linux and FreeBSD.
License
Copyright (c) 2016-2023 Dr. Ralf S. Engelschall (http://engelschall.com/)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.