údržba
This commit is contained in:
5
CyLukTs/lukan/node_modules/cachedir/.travis.yml
generated
vendored
Normal file
5
CyLukTs/lukan/node_modules/cachedir/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '6'
|
||||
- '8'
|
||||
- '10'
|
50
CyLukTs/lukan/node_modules/cachedir/index.js
generated
vendored
Normal file
50
CyLukTs/lukan/node_modules/cachedir/index.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
|
||||
function posix (id) {
|
||||
const cacheHome = process.env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache')
|
||||
return path.join(cacheHome, id)
|
||||
}
|
||||
|
||||
function darwin (id) {
|
||||
return path.join(os.homedir(), 'Library', 'Caches', id)
|
||||
}
|
||||
|
||||
function win32 (id) {
|
||||
const appData = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local')
|
||||
return path.join(appData, id, 'Cache')
|
||||
}
|
||||
|
||||
const implementation = (function () {
|
||||
switch (os.platform()) {
|
||||
case 'darwin':
|
||||
return darwin
|
||||
case 'win32':
|
||||
return win32
|
||||
case 'aix':
|
||||
case 'android':
|
||||
case 'freebsd':
|
||||
case 'linux':
|
||||
case 'netbsd':
|
||||
case 'openbsd':
|
||||
case 'sunos':
|
||||
return posix
|
||||
default:
|
||||
console.error(`(node:${process.pid}) [cachedir] Warning: the platform "${os.platform()}" is not currently supported by node-cachedir, falling back to "posix". Please file an issue with your platform here: https://github.com/LinusU/node-cachedir/issues/new`)
|
||||
return posix
|
||||
}
|
||||
}())
|
||||
|
||||
module.exports = function cachedir (id) {
|
||||
if (typeof id !== 'string') {
|
||||
throw new TypeError('id is not a string')
|
||||
}
|
||||
if (id.length === 0) {
|
||||
throw new Error('id cannot be empty')
|
||||
}
|
||||
if (/[^0-9a-zA-Z-]/.test(id)) {
|
||||
throw new Error('id cannot contain special characters')
|
||||
}
|
||||
|
||||
return implementation(id)
|
||||
}
|
20
CyLukTs/lukan/node_modules/cachedir/license
generated
vendored
Normal file
20
CyLukTs/lukan/node_modules/cachedir/license
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2014, 2016, 2018 Linus Unnebäck
|
||||
|
||||
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.
|
19
CyLukTs/lukan/node_modules/cachedir/package.json
generated
vendored
Normal file
19
CyLukTs/lukan/node_modules/cachedir/package.json
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "cachedir",
|
||||
"version": "2.3.0",
|
||||
"license": "MIT",
|
||||
"repository": "LinusU/node-cachedir",
|
||||
"author": "Linus Unnebäck <linus@folkdatorn.se>",
|
||||
"scripts": {
|
||||
"test": "standard && mocha"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"mocha": "^5.2.0",
|
||||
"proxyquire": "^2.0.1",
|
||||
"standard": "^14.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
}
|
27
CyLukTs/lukan/node_modules/cachedir/readme.md
generated
vendored
Normal file
27
CyLukTs/lukan/node_modules/cachedir/readme.md
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
# node-cachedir
|
||||
|
||||
Provides a directory where the OS wants you to store cached files.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
npm install --save cachedir
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
const cachedir = require('cachedir')
|
||||
|
||||
console.log(cachedir('myapp'))
|
||||
// e.g.
|
||||
//=> '/Users/linus/Library/Caches/myapp'
|
||||
//=> '/home/linus/.cache/myapp'
|
||||
//=> 'C:\Users\linus\AppData\Local\myapp\Cache'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `cachedir(name: string) => string`
|
||||
|
||||
Return path to an appropriate place to store cache files.
|
86
CyLukTs/lukan/node_modules/cachedir/test.js
generated
vendored
Normal file
86
CyLukTs/lukan/node_modules/cachedir/test.js
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
/* eslint-env mocha */
|
||||
|
||||
const assert = require('assert')
|
||||
const os = require('os')
|
||||
const proxyquire = require('proxyquire')
|
||||
|
||||
const platforms = [
|
||||
['aix', `${os.homedir()}/.cache/linusu`],
|
||||
['darwin', `${os.homedir()}/Library/Caches/linusu`],
|
||||
['freebsd', `${os.homedir()}/.cache/linusu`],
|
||||
['linux', `${os.homedir()}/.cache/linusu`],
|
||||
['netbsd', `${os.homedir()}/.cache/linusu`],
|
||||
['openbsd', `${os.homedir()}/.cache/linusu`],
|
||||
['sunos', `${os.homedir()}/.cache/linusu`],
|
||||
['win32', `${os.homedir()}/AppData/Local/linusu/Cache`]
|
||||
]
|
||||
|
||||
platforms.forEach((platform) => {
|
||||
describe(platform[0], () => {
|
||||
let cachedir
|
||||
|
||||
before(() => {
|
||||
const os = {
|
||||
platform () { return platform[0] }
|
||||
}
|
||||
|
||||
cachedir = proxyquire('./', { os })
|
||||
})
|
||||
|
||||
it('should give the correct path', () => {
|
||||
const actual = cachedir('linusu')
|
||||
const expected = platform[1]
|
||||
|
||||
assert.strictEqual(actual, expected)
|
||||
})
|
||||
|
||||
if (platform[0] === 'win32') {
|
||||
describe('when LOCALAPPDATA is set', () => {
|
||||
it('should give the correct path', () => {
|
||||
const oldLocalAppData = process.env.LOCALAPPDATA
|
||||
process.env.LOCALAPPDATA = 'X:/LocalAppData'
|
||||
const actual = cachedir('linusu')
|
||||
process.env.LOCALAPPDATA = oldLocalAppData
|
||||
const expected = 'X:/LocalAppData/linusu/Cache'
|
||||
|
||||
assert.strictEqual(actual, expected)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
it('should throw on bad input', () => {
|
||||
assert.throws(() => cachedir())
|
||||
assert.throws(() => cachedir(''))
|
||||
assert.throws(() => cachedir({}))
|
||||
assert.throws(() => cachedir([]))
|
||||
assert.throws(() => cachedir(null))
|
||||
assert.throws(() => cachedir(1337))
|
||||
assert.throws(() => cachedir('test!!'))
|
||||
assert.throws(() => cachedir(undefined))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('fallback', () => {
|
||||
it('should fallback to posix with warning', () => {
|
||||
const originalError = console.error
|
||||
|
||||
try {
|
||||
const logs = []
|
||||
console.error = (msg) => logs.push(msg)
|
||||
|
||||
const os = { platform: () => 'test' }
|
||||
const cachedir = proxyquire('./', { os })
|
||||
|
||||
const actual = cachedir('linusu')
|
||||
const expected = `${os.homedir()}/.cache/linusu`
|
||||
assert.strictEqual(actual, expected)
|
||||
|
||||
assert.deepStrictEqual(logs, [
|
||||
`(node:${process.pid}) [cachedir] Warning: the platform "test" is not currently supported by node-cachedir, falling back to "posix". Please file an issue with your platform here: https://github.com/LinusU/node-cachedir/issues/new`
|
||||
])
|
||||
} finally {
|
||||
console.error = originalError
|
||||
}
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user