diff options
author | Michael Perrotte <mike@npmjs.com> | 2020-01-28 02:44:13 +0300 |
---|---|---|
committer | Michael Perrotte <mike@npmjs.com> | 2020-01-28 20:27:42 +0300 |
commit | c9b69d569fec7944375a746e9c08a6fa9bec96ff (patch) | |
tree | 98578810736ebaed0f0e4b33c38bbcd5b411e6dd /node_modules/env-paths | |
parent | e8dbaf452a1f6c5350bb0c37059b89a7448e7986 (diff) |
node-gyp@5.0.7
Diffstat (limited to 'node_modules/env-paths')
-rw-r--r-- | node_modules/env-paths/index.d.ts | 69 | ||||
-rw-r--r-- | node_modules/env-paths/index.js | 27 | ||||
-rw-r--r-- | node_modules/env-paths/license | 20 | ||||
-rw-r--r-- | node_modules/env-paths/package.json | 37 | ||||
-rw-r--r-- | node_modules/env-paths/readme.md | 7 |
5 files changed, 113 insertions, 47 deletions
diff --git a/node_modules/env-paths/index.d.ts b/node_modules/env-paths/index.d.ts new file mode 100644 index 000000000..e57fa8f66 --- /dev/null +++ b/node_modules/env-paths/index.d.ts @@ -0,0 +1,69 @@ +declare namespace envPaths { + export interface Options { + /** + __Don't use this option unless you really have to!__ + + Suffix appended to the project name to avoid name conflicts with native apps. Pass an empty string to disable it. + + @default 'nodejs' + */ + readonly suffix?: string; + } + + export interface Paths { + /** + Directory for data files. + */ + readonly data: string; + + /** + Directory for data files. + */ + readonly config: string; + + /** + Directory for non-essential data files. + */ + readonly cache: string; + + /** + Directory for log files. + */ + readonly log: string; + + /** + Directory for temporary files. + */ + readonly temp: string; + } +} + +declare const envPaths: { + /** + Get paths for storing things like data, config, cache, etc. + + @param name - Name of your project. Used to generate the paths. + @returns The paths to use for your project on current OS. + + @example + ``` + import envPaths = require('env-paths'); + + const paths = envPaths('MyApp'); + + paths.data; + //=> '/home/sindresorhus/.local/share/MyApp-nodejs' + + paths.config + //=> '/home/sindresorhus/.config/MyApp-nodejs' + ``` + */ + (name: string, options?: envPaths.Options): envPaths.Paths; + + // TODO: Remove this for the next major release, refactor the whole definition to: + // declare function envPaths(name: string, options?: envPaths.Options): envPaths.Paths; + // export = envPaths; + default: typeof envPaths; +}; + +export = envPaths; diff --git a/node_modules/env-paths/index.js b/node_modules/env-paths/index.js index 4a04b712f..7e7b50baa 100644 --- a/node_modules/env-paths/index.js +++ b/node_modules/env-paths/index.js @@ -4,7 +4,7 @@ const os = require('os'); const homedir = os.homedir(); const tmpdir = os.tmpdir(); -const env = process.env; +const {env} = process; const macos = name => { const library = path.join(homedir, 'Library'); @@ -19,14 +19,15 @@ const macos = name => { }; const windows = name => { - const appData = env.LOCALAPPDATA || path.join(homedir, 'AppData', 'Local'); + const appData = env.APPDATA || path.join(homedir, 'AppData', 'Roaming'); + const localAppData = env.LOCALAPPDATA || path.join(homedir, 'AppData', 'Local'); return { - // data/config/cache/log are invented by me as Windows isn't opinionated about this - data: path.join(appData, name, 'Data'), + // Data/config/cache/log are invented by me as Windows isn't opinionated about this + data: path.join(localAppData, name, 'Data'), config: path.join(appData, name, 'Config'), - cache: path.join(appData, name, 'Cache'), - log: path.join(appData, name, 'Log'), + cache: path.join(localAppData, name, 'Cache'), + log: path.join(localAppData, name, 'Log'), temp: path.join(tmpdir, name) }; }; @@ -45,16 +46,16 @@ const linux = name => { }; }; -module.exports = (name, opts) => { +const envPaths = (name, options) => { if (typeof name !== 'string') { throw new TypeError(`Expected string, got ${typeof name}`); } - opts = Object.assign({suffix: 'nodejs'}, opts); + options = Object.assign({suffix: 'nodejs'}, options); - if (opts.suffix) { - // add suffix to prevent possible conflict with native apps - name += `-${opts.suffix}`; + if (options.suffix) { + // Add suffix to prevent possible conflict with native apps + name += `-${options.suffix}`; } if (process.platform === 'darwin') { @@ -67,3 +68,7 @@ module.exports = (name, opts) => { return linux(name); }; + +module.exports = envPaths; +// TODO: Remove this for the next major release +module.exports.default = envPaths; diff --git a/node_modules/env-paths/license b/node_modules/env-paths/license index 654d0bfe9..e7af2f771 100644 --- a/node_modules/env-paths/license +++ b/node_modules/env-paths/license @@ -1,21 +1,9 @@ -The MIT License (MIT) +MIT License Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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: +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 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. +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. diff --git a/node_modules/env-paths/package.json b/node_modules/env-paths/package.json index 3b1dfb74d..6af671147 100644 --- a/node_modules/env-paths/package.json +++ b/node_modules/env-paths/package.json @@ -1,27 +1,27 @@ { - "_from": "env-paths@^1.0.0", - "_id": "env-paths@1.0.0", + "_from": "env-paths@^2.2.0", + "_id": "env-paths@2.2.0", "_inBundle": false, - "_integrity": "sha1-QWgTO0K7BcOKNbGuQ5fIKYqzaeA=", + "_integrity": "sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA==", "_location": "/env-paths", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "env-paths@^1.0.0", + "raw": "env-paths@^2.2.0", "name": "env-paths", "escapedName": "env-paths", - "rawSpec": "^1.0.0", + "rawSpec": "^2.2.0", "saveSpec": null, - "fetchSpec": "^1.0.0" + "fetchSpec": "^2.2.0" }, "_requiredBy": [ "/node-gyp" ], - "_resolved": "https://registry.npmjs.org/env-paths/-/env-paths-1.0.0.tgz", - "_shasum": "4168133b42bb05c38a35b1ae4397c8298ab369e0", - "_spec": "env-paths@^1.0.0", - "_where": "/Users/isaacs/dev/npm/cli/node_modules/node-gyp", + "_resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.0.tgz", + "_shasum": "cdca557dc009152917d6166e2febe1f039685e43", + "_spec": "env-paths@^2.2.0", + "_where": "/Users/mperrotte/npminc/cli/node_modules/node-gyp", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", @@ -34,14 +34,16 @@ "deprecated": false, "description": "Get paths for storing things like data, config, cache, etc", "devDependencies": { - "ava": "*", - "xo": "*" + "ava": "^1.4.1", + "tsd": "^0.7.1", + "xo": "^0.24.0" }, "engines": { - "node": ">=4" + "node": ">=6" }, "files": [ - "index.js" + "index.js", + "index.d.ts" ], "homepage": "https://github.com/sindresorhus/env-paths#readme", "keywords": [ @@ -69,10 +71,7 @@ "url": "git+https://github.com/sindresorhus/env-paths.git" }, "scripts": { - "test": "xo && ava" + "test": "xo && ava && tsd" }, - "version": "1.0.0", - "xo": { - "esnext": true - } + "version": "2.2.0" } diff --git a/node_modules/env-paths/readme.md b/node_modules/env-paths/readme.md index 0bdc2ac14..ec3439316 100644 --- a/node_modules/env-paths/readme.md +++ b/node_modules/env-paths/readme.md @@ -2,11 +2,13 @@ > Get paths for storing things like data, config, cache, etc +Uses the correct OS-specific paths. Most developers get this wrong. + ## Install ``` -$ npm install --save env-paths +$ npm install env-paths ``` @@ -14,6 +16,7 @@ $ npm install --save env-paths ```js const envPaths = require('env-paths'); + const paths = envPaths('MyApp'); paths.data; @@ -36,6 +39,8 @@ Name of your project. Used to generate the paths. #### options +Type: `Object` + ##### suffix Type: `string`<br> |