Comparing version
@@ -1,33 +0,39 @@ | ||
"use strict"; | ||
var os = require("os"); | ||
'use strict' | ||
var os = require('os') | ||
/** | ||
Cross-platform home directory retriever, tested on Windows XP, Windows 8.1, Mac OSX, Linux. Will use the built-in [`os.homedir`](https://nodejs.org/api/os.html#os_os_homedir) if available. | ||
@module home-path | ||
* Cross-platform home directory retriever, tested on Windows XP and above, Mac OSX and Linux. Will use the built-in [`os.homedir`](https://nodejs.org/api/os.html#os_os_homedir) if available. | ||
* @module home-path | ||
* @example | ||
* var getHomePath = require('home-path') | ||
*/ | ||
module.exports = os.homedir ? os.homedir : getHomePath; | ||
module.exports = os.homedir ? os.homedir : getHomePath | ||
/** | ||
@alias module:home-path | ||
@example | ||
Mac OSX & Linux | ||
```js | ||
> var getHomePath = require("home-path"); | ||
> getHomePath() | ||
'/Users/Lloyd' | ||
``` | ||
Windows 8.1 | ||
```js | ||
> var getHomePath = require("home-path"); | ||
> getHomePath() | ||
'C:\\Users\\Lloyd' | ||
``` | ||
* @alias module:home-path | ||
* @example | ||
* Mac OSX | ||
* ```js | ||
* > getHomePath() | ||
* '/Users/Lloyd' | ||
* ``` | ||
* | ||
* Ubuntu Linux | ||
* ```js | ||
* > getHomePath() | ||
* '/home/lloyd' | ||
* ``` | ||
* | ||
* Windows 8.1 | ||
* ```js | ||
* > getHomePath() | ||
* 'C:\\Users\\Lloyd' | ||
* ``` | ||
*/ | ||
function getHomePath() { | ||
if (process.platform === "win32") { | ||
return process.env.USERPROFILE || process.env.HOMEDRIVE + process.env.HOMEPATH || process.env.HOME; | ||
} else { | ||
return process.env.HOME | ||
} | ||
}; | ||
function getHomePath () { | ||
if (process.platform === 'win32') { | ||
return process.env.USERPROFILE || process.env.HOMEDRIVE + process.env.HOMEPATH || process.env.HOME | ||
} else { | ||
return process.env.HOME | ||
} | ||
} |
{ | ||
"name": "home-path", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Cross-platform home directory retriever", | ||
@@ -17,9 +17,8 @@ "repository": "https://github.com/75lb/home-path.git", | ||
"test": "tape test/*.js", | ||
"lint": "jshint lib/*.js test/*.js; echo", | ||
"docs": "jsdoc2md -t jsdoc2md/README.hbs lib/*.js > README.md; echo" | ||
}, | ||
"devDependencies": { | ||
"jsdoc-to-markdown": "^1.1.1", | ||
"tape": "^4" | ||
"jsdoc-to-markdown": "^1.3.3", | ||
"tape": "^4.4" | ||
} | ||
} |
[](https://www.npmjs.org/package/home-path) | ||
[](https://www.npmjs.org/package/home-path) | ||
[](https://www.npmjs.org/package/home-path) | ||
[](https://travis-ci.org/75lb/home-path) | ||
[](https://david-dm.org/75lb/home-path) | ||
[](https://github.com/feross/standard) | ||
<a name="module_home-path"></a> | ||
## home-path | ||
Cross-platform home directory retriever, tested on Windows XP, Windows 8.1, Mac OSX, Linux. Will use the built-in [`os.homedir`](https://nodejs.org/api/os.html#os_os_homedir) if available. | ||
Cross-platform home directory retriever, tested on Windows XP and above, Mac OSX and Linux. Will use the built-in [`os.homedir`](https://nodejs.org/api/os.html#os_os_homedir) if available. | ||
**Example** | ||
```js | ||
var getHomePath = require('home-path') | ||
``` | ||
<a name="exp_module_home-path--getHomePath"></a> | ||
@@ -14,5 +19,4 @@ ### getHomePath() ⏏ | ||
**Example** | ||
Mac OSX & Linux | ||
Mac OSX | ||
```js | ||
> var getHomePath = require("home-path"); | ||
> getHomePath() | ||
@@ -22,5 +26,10 @@ '/Users/Lloyd' | ||
Ubuntu Linux | ||
```js | ||
> getHomePath() | ||
'/home/lloyd' | ||
``` | ||
Windows 8.1 | ||
```js | ||
> var getHomePath = require("home-path"); | ||
> getHomePath() | ||
@@ -27,0 +36,0 @@ 'C:\\Users\\Lloyd' |
@@ -1,7 +0,7 @@ | ||
var test = require("tape"); | ||
var getHomePath = require("../"); | ||
var test = require('tape') | ||
var getHomePath = require('../') | ||
test("returns string", function(t){ | ||
t.equal(typeof getHomePath(), "string"); | ||
t.end(); | ||
}); | ||
test('returns string', function (t) { | ||
t.equal(typeof getHomePath(), 'string') | ||
t.end() | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
43
19.44%40
29.03%4664
-1.71%8
-11.11%