README.md (3591B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # configdir 22 23 > Return a directory for user-specific configuration files. 24 25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> 26 27 <section class="intro"> 28 29 </section> 30 31 <!-- /.intro --> 32 33 <!-- Package usage documentation. --> 34 35 <section class="usage"> 36 37 ## Usage 38 39 ```javascript 40 var configdir = require( '@stdlib/os/configdir' ); 41 ``` 42 43 #### configdir( \[path] ) 44 45 Returns a directory for user-specific configuration files. 46 47 ```javascript 48 var dir = configdir(); 49 // e.g., returns '/Users/<username>/Library/Preferences' 50 ``` 51 52 To append a `path` to the base directory, provide a `path` argument. 53 54 ```javascript 55 var dir = configdir( 'appname/config' ); 56 // e.g., returns '/Users/<username>/Library/Preferences/appname/config' 57 ``` 58 59 On non-Windows platforms, if the function is unable to locate the current user's [`home`][@stdlib/os/homedir] directory, the function returns `null`. Similarly, on Windows platforms, if the function is unable to locate an application data directory, the function also returns `null`. 60 61 </section> 62 63 <!-- /.usage --> 64 65 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 66 67 <section class="notes"> 68 69 ## Notes 70 71 - On Windows platforms, the function first checks for a `LOCALAPPDATA` [environment variable][environment-variable-windows] before checking for an `APPDATA` [environment variable][environment-variable-windows]. This means that machine specific user configuration files have precedence over roaming user configuration files. 72 73 </section> 74 75 <!-- /.notes --> 76 77 <!-- Package usage examples. --> 78 79 <section class="examples"> 80 81 ## Examples 82 83 <!-- eslint no-undef: "error" --> 84 85 ```javascript 86 var configdir = require( '@stdlib/os/configdir' ); 87 88 console.log( configdir( 'appy/config' ) ); 89 ``` 90 91 </section> 92 93 <!-- /.examples --> 94 95 * * * 96 97 <section class="cli"> 98 99 ## CLI 100 101 <section class="usage"> 102 103 ### Usage 104 105 ```text 106 Usage: configdir [options] 107 108 Options: 109 110 -h, --help Print this message. 111 -V, --version Print the package version. 112 ``` 113 114 </section> 115 116 <!-- /.usage --> 117 118 <section class="examples"> 119 120 ### Examples 121 122 ```bash 123 $ configdir 124 e.g., /Users/<username>/Library/Preferences 125 ``` 126 127 </section> 128 129 <!-- /.examples --> 130 131 </section> 132 133 <!-- /.cli --> 134 135 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 136 137 <section class="references"> 138 139 </section> 140 141 <!-- /.references --> 142 143 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 144 145 <section class="links"> 146 147 [environment-variable-windows]: https://en.wikipedia.org/wiki/Environment_variable#Windows 148 149 [@stdlib/os/homedir]: https://www.npmjs.com/package/@stdlib/os/tree/main/homedir 150 151 </section> 152 153 <!-- /.links -->