System Path Determination (Home and Data Directories)
npm install syspath
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
------------
``sh`
$ npm install syspath
Usage
-----
`jshomeDir: ${homeDir}, dataDir: ${dataDir}
import syspath from "syspath"
let { homeDir, dataDir } = syspath({ appName: "foo" })
console.log()`
Application Programming Interface
---------------------------------
`ts`
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 and dataDirAutoCreate is true). TheparseInt("0755", 8) & ~process.umask()
default is .
- The dataDirAutoCreate forces the automatic creation of the dataDirtrue
(if still not existing, which is usually the case on the initial usage).
By default this is .
- The dataDirAutoRemove forces the automatic removal of the dataDir iftrue
it is still empty at the application termination time. By default this
is .
- The homeDir is the resolved path to the home directory of the user%USERPROFILE%
the application is executed under. The home directory is usually
on Windows or $HOME on Mac OS X, Linux and FreeBSD.
- The dataDir is the resolved path to the dedicated data directory for%APPDATA%/
the application. The data directory is usually on$HOME/Library/Application Support/
Windows, on Mac OS X and$XDG_CONFIG_HOME/
or $HOME/.config/
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.