Comparing version 0.1.1 to 0.1.2
48
index.js
@@ -0,34 +1,32 @@ | ||
var os = require('os') | ||
var path = require('path') | ||
var os = require('os'); | ||
var env = process.env; | ||
function linux (id) { | ||
return path.join(os.homedir(), '.cache', id) | ||
} | ||
var implementation; | ||
switch(os.type()) { | ||
case 'Darwin': | ||
implementation = function (id) { | ||
return env.HOME + '/Library/Caches/' + id; | ||
}; | ||
break; | ||
case 'Linux': | ||
implementation = function (id) { | ||
return env.HOME + '/.cache/' + id; | ||
}; | ||
break; | ||
default: | ||
throw new Error('Your OS is currently not supported by node-cachedir.'); | ||
function darwin (id) { | ||
return path.join(os.homedir(), 'Library', 'Caches', id) | ||
} | ||
var implementation = (function () { | ||
switch (os.platform()) { | ||
case 'linux': return linux | ||
case 'darwin': return darwin | ||
default: throw new Error('Your OS is currently not supported by node-cachedir.') | ||
} | ||
}()) | ||
module.exports = function (id) { | ||
if(typeof id !== 'string') { | ||
throw new TypeError('id is not a string'); | ||
if (typeof id !== 'string') { | ||
throw new TypeError('id is not a string') | ||
} | ||
if(id.length === 0) { | ||
throw new Error('id cannot be empty'); | ||
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'); | ||
if (/[^0-9a-zA-Z-]/.test(id)) { | ||
throw new Error('id cannot contain special characters') | ||
} | ||
return implementation(id); | ||
}; | ||
return implementation(id) | ||
} |
{ | ||
"name": "cachedir", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "MIT", | ||
"author": "Linus Unnebäck <linus@folkdatorn.se>", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/LinusU/node-cachedir.git" | ||
"repository": "LinusU/node-cachedir", | ||
"scripts": { | ||
"test": "standard && mocha" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^2.4.5", | ||
"proxyquire": "^1.7.4", | ||
"standard": "^6.0.8" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
3643
6
61
3
1