Comparing version 0.1.0 to 0.1.1
24
index.js
var os = require('os'); | ||
var env = process.env; | ||
var impl = null; | ||
var implementation; | ||
switch(os.type()) { | ||
case 'Darwin': | ||
impl = function (id) { | ||
implementation = function (id) { | ||
return env.HOME + '/Library/Caches/' + id; | ||
@@ -13,3 +14,3 @@ }; | ||
case 'Linux': | ||
impl = function (id) { | ||
implementation = function (id) { | ||
return env.HOME + '/.cache/' + id; | ||
@@ -22,13 +23,14 @@ }; | ||
module.exports = exports = function (id) { | ||
if(typeof(id) != 'string') { | ||
throw new Error('Argument id should be a string'); | ||
module.exports = function (id) { | ||
if(typeof id !== 'string') { | ||
throw new TypeError('id is not a string'); | ||
} | ||
if(id.length == 0) { | ||
throw new Error('Argument id cannot be empty'); | ||
if(id.length === 0) { | ||
throw new Error('id cannot be empty'); | ||
} | ||
if(/[ \n\r\t]/.test(id)) { | ||
throw new Error('Argument id cannot contain spaces'); | ||
if(/[^0-9a-zA-Z-]/.test(id)) { | ||
throw new Error('id cannot contain special characters'); | ||
} | ||
return impl(id); | ||
return implementation(id); | ||
}; |
{ | ||
"name": "cachedir", | ||
"version": "0.1.0", | ||
"main": "index.js" | ||
"version": "0.1.1", | ||
"license": "MIT", | ||
"author": "Linus Unnebäck <linus@folkdatorn.se>", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/LinusU/node-cachedir.git" | ||
} | ||
} |
@@ -1,4 +0,19 @@ | ||
node-cachedir | ||
============= | ||
# node-cachedir | ||
Get a directory for your caching needs | ||
Provides a directory where the OS wants you to store cached files. | ||
## Installation | ||
```sh | ||
npm install cachedir | ||
``` | ||
## Usage | ||
```javascript | ||
var cachedir = require('cachedir'); | ||
var path = cachedir('linusu'); | ||
// `dir` now contains the path under which you should store cached files | ||
``` |
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
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
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
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
2441
1
20
1