Socket
Socket
Sign inDemoInstall

cachedir

Package Overview
Dependencies
1
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.0 to 2.0.0

license

14

index.js

@@ -1,7 +0,7 @@

var os = require('os')
var path = require('path')
var homedir = require('os-homedir')
const os = require('os')
const path = require('path')
const homedir = require('os-homedir')
function posix (id) {
var cacheHome = process.env.XDG_CACHE_HOME || path.join(homedir(), '.cache')
const cacheHome = process.env.XDG_CACHE_HOME || path.join(homedir(), '.cache')
return path.join(cacheHome, id)

@@ -15,7 +15,7 @@ }

function win32 (id) {
var appData = process.env.LOCALAPPDATA || path.join(homedir(), 'AppData', 'Local')
const appData = process.env.LOCALAPPDATA || path.join(homedir(), 'AppData', 'Local')
return path.join(appData, id, 'Cache')
}
var implementation = (function () {
const implementation = (function () {
switch (os.platform()) {

@@ -31,3 +31,3 @@ case 'android': return posix

module.exports = function (id) {
module.exports = function cachedir (id) {
if (typeof id !== 'string') {

@@ -34,0 +34,0 @@ throw new TypeError('id is not a string')

{
"name": "cachedir",
"version": "1.3.0",
"version": "2.0.0",
"license": "MIT",
"repository": "LinusU/node-cachedir",
"author": "Linus Unnebäck <linus@folkdatorn.se>",
"main": "index.js",
"repository": "LinusU/node-cachedir",
"scripts": {
"test": "standard && mocha"
},
"dependencies": {
"os-homedir": "^1.0.1"
},
"devDependencies": {
"mocha": "^4.1.0",
"proxyquire": "^1.7.4",
"standard": "^10.0.3"
"mocha": "^5.2.0",
"proxyquire": "^2.0.1",
"standard": "^11.0.1"
},
"dependencies": {
"os-homedir": "^1.0.1"
"engines": {
"node": ">=6"
}
}
/* eslint-env mocha */
var assert = require('assert')
var homedir = require('os-homedir')
var proxyquire = require('proxyquire')
const assert = require('assert')
const homedir = require('os-homedir')
const proxyquire = require('proxyquire')
var platforms = [
['darwin', homedir() + '/Library/Caches/linusu'],
['freebsd', homedir() + '/.cache/linusu'],
['linux', homedir() + '/.cache/linusu'],
['win32', homedir() + '/AppData/Local/linusu/Cache']
const platforms = [
['darwin', `${homedir()}/Library/Caches/linusu`],
['freebsd', `${homedir()}/.cache/linusu`],
['linux', `${homedir()}/.cache/linusu`],
['win32', `${homedir()}/AppData/Local/linusu/Cache`]
]
platforms.forEach(function (platform) {
describe(platform[0], function () {
var cachedir
describe(platform[0], () => {
let cachedir
before(function () {
var os = {
platform: function () { return platform[0] }
before(() => {
const os = {
platform () { return platform[0] }
}
cachedir = proxyquire('./', { os: os })
cachedir = proxyquire('./', { os })
})
it('should give the correct path', function () {
var actual = cachedir('linusu')
var expected = platform[1]
it('should give the correct path', () => {
const actual = cachedir('linusu')
const expected = platform[1]

@@ -34,9 +34,9 @@ assert.equal(actual, expected)

if (platform[0] === 'win32') {
describe('when LOCALAPPDATA is set', function () {
it('should give the correct path', function () {
var oldLocalAppData = process.env.LOCALAPPDATA
describe('when LOCALAPPDATA is set', () => {
it('should give the correct path', () => {
const oldLocalAppData = process.env.LOCALAPPDATA
process.env.LOCALAPPDATA = 'X:/LocalAppData'
var actual = cachedir('linusu')
const actual = cachedir('linusu')
process.env.LOCALAPPDATA = oldLocalAppData
var expected = 'X:/LocalAppData/linusu/Cache'
const expected = 'X:/LocalAppData/linusu/Cache'

@@ -48,13 +48,13 @@ assert.equal(actual, expected)

it('should throw on bad input', function () {
assert.throws(function () { cachedir() })
assert.throws(function () { cachedir('') })
assert.throws(function () { cachedir({}) })
assert.throws(function () { cachedir([]) })
assert.throws(function () { cachedir(null) })
assert.throws(function () { cachedir(1337) })
assert.throws(function () { cachedir('test!!') })
assert.throws(function () { cachedir(undefined) })
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))
})
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc