Socket
Socket
Sign inDemoInstall

cachedir

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cachedir - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

22

index.js

@@ -20,9 +20,17 @@ const os = require('os')

switch (os.platform()) {
case 'android': return posix
case 'darwin': return darwin
case 'freebsd': return posix
case 'linux': return posix
case 'openbsd': return posix
case 'win32': return win32
default: throw new Error('Your OS "' + os.platform() + '" is currently not supported by node-cachedir.')
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
}

@@ -29,0 +37,0 @@ }())

{
"name": "cachedir",
"version": "2.2.0",
"version": "2.3.0",
"license": "MIT",

@@ -14,3 +14,3 @@ "repository": "LinusU/node-cachedir",

"proxyquire": "^2.0.1",
"standard": "^11.0.1"
"standard": "^14.3.1"
},

@@ -17,0 +17,0 @@ "engines": {

@@ -8,10 +8,13 @@ /* eslint-env mocha */

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(function (platform) {
platforms.forEach((platform) => {
describe(platform[0], () => {

@@ -32,3 +35,3 @@ let cachedir

assert.equal(actual, expected)
assert.strictEqual(actual, expected)
})

@@ -45,3 +48,3 @@

assert.equal(actual, expected)
assert.strictEqual(actual, expected)
})

@@ -63,1 +66,25 @@ })

})
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
}
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc