Comparing version
@@ -62,4 +62,6 @@ # :eight_spoked_asterisk: :stars: :sparkles: :dizzy: :star2: :star2: :sparkles: :dizzy: :star2: :star2: Contributing :star: :star2: :dizzy: :sparkles: :star: :star2: :dizzy: :sparkles: :stars: :eight_spoked_asterisk: | ||
[1]: https://github.com/IonicaBizau/node-abs/issues | ||
[2]: https://github.com/IonicaBizau/code-style | ||
[1]: https://github.com/IonicaBizau/abs/issues | ||
[2]: https://github.com/IonicaBizau/code-style |
@@ -1,12 +0,10 @@ | ||
// Dependencies | ||
var Abs = require("../lib"); | ||
const abs = require("../lib"); | ||
console.log(Abs("/foo")); | ||
console.log(abs("/foo")); | ||
// => "/foo" | ||
console.log(Abs("foo")); | ||
console.log(abs("foo")); | ||
// => "/path/to/where/you/are/foo" | ||
console.log(Abs("~/foo")); | ||
console.log(abs("~/foo")); | ||
// => "/home/username/foo" | ||
@@ -1,23 +0,26 @@ | ||
// Dependencies | ||
var Path = require("path") | ||
, Ul = require("ul") | ||
; | ||
"use strict"; | ||
const path = require("path") | ||
, ul = require("ul") | ||
; | ||
/** | ||
* Abs | ||
* abs | ||
* Computes the absolute path of an input. | ||
* | ||
* @name Abs | ||
* @name abs | ||
* @function | ||
* @param {String} input The input path. | ||
* @param {String} input The input path (if not provided, the current | ||
* working directory will be returned). | ||
* @return {String} The absolute path. | ||
*/ | ||
function Abs(input) { | ||
function abs(input) { | ||
if (!input) { return process.cwd(); } | ||
if (input.charAt(0) === "/") { return input; } | ||
if (input.charAt(0) === "~" && input.charAt(1) === "/") { | ||
input = Ul.HOME_DIR + input.substr(1); | ||
input = ul.HOME_DIR + input.substr(1); | ||
} | ||
return Path.resolve(input); | ||
return path.resolve(input); | ||
} | ||
module.exports = Abs; | ||
module.exports = abs; |
{ | ||
"name": "abs", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "A library to convert a path into an absolute path.", | ||
@@ -21,3 +21,3 @@ "main": "lib/index.js", | ||
"type": "git", | ||
"url": "git@github.com:IonicaBizau/node-abs.git" | ||
"url": "git@github.com:IonicaBizau/abs.git" | ||
}, | ||
@@ -31,5 +31,5 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/IonicaBizau/node-abs/issues" | ||
"url": "https://github.com/IonicaBizau/abs/issues" | ||
}, | ||
"homepage": "https://github.com/IonicaBizau/node-abs" | ||
} | ||
"homepage": "https://github.com/IonicaBizau/abs" | ||
} |
103
README.md
@@ -0,1 +1,2 @@ | ||
# abs [][paypal-donations] [](https://www.npmjs.com/package/abs) [](https://www.npmjs.com/package/abs) [](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github) | ||
@@ -5,3 +6,3 @@ | ||
## Installation | ||
## :cloud: Installation | ||
@@ -12,25 +13,28 @@ ```sh | ||
## Example | ||
## :clipboard: Example | ||
```js | ||
// Dependencies | ||
var Abs = require("abs"); | ||
const abs = require("abs"); | ||
console.log(Abs("/foo")); | ||
console.log(abs("/foo")); | ||
// => "/foo" | ||
console.log(Abs("foo")); | ||
console.log(abs("foo")); | ||
// => "/path/to/where/you/are/foo" | ||
console.log(Abs("~/foo")); | ||
console.log(abs("~/foo")); | ||
// => "/home/username/foo" | ||
``` | ||
## Documentation | ||
## :memo: Documentation | ||
### `Abs(input)` | ||
### `abs(input)` | ||
Computes the absolute path of an input. | ||
#### Params | ||
- **String** `input`: The input path. | ||
- **String** `input`: The input path (if not provided, the current working directory will be returned). | ||
@@ -40,50 +44,45 @@ #### Return | ||
## How to contribute | ||
## :yum: How to contribute | ||
Have an idea? Found a bug? See [how to contribute][contributing]. | ||
## Where is this library used? | ||
## :dizzy: Where is this library used? | ||
If you are using this library in one of your projects, add it in this list. :sparkles: | ||
- [`bible`](https://github.com/BibleJS/BibleApp) | ||
- [`cdnjs-importer`](https://github.com/cdnjs/cdnjs-importer) | ||
- [`bible`](https://github.com/BibleJS/BibleApp)—Read the Holy Bible via the command line. | ||
- [`blah`](https://github.com/IonicaBizau/blah)—A command line tool to optimize the repetitive actions. | ||
- [`cdnjs-importer`](https://github.com/cdnjs/cdnjs-importer)—Easy way to import a library into CDNJS. | ||
- [`cli-sunset`](https://github.com/IonicaBizau/cli-sunset)—A fancy command line tool for knowing the sunset time. | ||
- [`emojer-cli`](https://github.com/IonicaBizau/emojer-cli#readme)—Command line tool for emojer. | ||
- [`engine-app`](https://github.com/jillix/engine-app#readme) (by jillix)—Engine app related helper functions. | ||
- [`engine-paths`](https://github.com/jillix/engine-paths#readme) (by jillix)—Keeping the Engine paths in one place. | ||
- [`engine-tools`](https://github.com/jillix/engine-tools) (by jillix)—Engine Tools library and CLI app. | ||
- [`fwatcher`](https://github.com/IonicaBizau/node-fwatcher)—Watch files for changes. | ||
- [`gh-notifier`](https://bitbucket.org/IonicaBizau/gh-notifier#readme)—Receive desktop notifications from your GitHub dashboard. | ||
- [`ghcal`](https://github.com/IonicaBizau/ghcal)—See the GitHub contributions calendar of a user in the command line. | ||
- [`git-issues`](https://github.com/softwarescales/git-issues) (by Gabriel Petrovay)—Git issues extension to list issues of a Git project | ||
- [`git-repos`](https://github.com/IonicaBizau/node-git-repos#readme)—Find all the git repositories in a specified directory, recursively. | ||
- [`git-stats`](https://github.com/IonicaBizau/git-stats)—Local git statistics including GitHub-like contributions calendars. | ||
- [`github-labeller`](https://github.com/IonicaBizau/github-labeller#readme)—Automagically create issue labels in your GitHub projects. | ||
- [`gpm`](https://github.com/IonicaBizau/gpm)—npm + git = gpm - Install NPM packages and dependencies from git repositories. | ||
- [`gry`](https://github.com/IonicaBizau/node-gry)—A minimalist NodeJS wrapper for the `git` commands. `gry` stands for the Git RepositorY. | ||
- [`idea`](https://github.com/IonicaBizau/idea)—A lightweight CLI tool and module for keeping ideas in a safe place quick and easy. | ||
- [`image-to-ascii-cli`](https://github.com/IonicaBizau/image-to-ascii-cli#readme)—View images in text format, in your terminal. | ||
- [`messager`](https://github.com/IonicaBizau/node-messager#readme)—Inter-process communication made simple. | ||
- [`mongof`](https://github.com/IonicaBizau/node-mongof)—Sync MongoDB collections with JSON files. | ||
- [`namy`](https://github.com/IonicaBizau/namy)—Gets the name of the exported function. | ||
- [`np-init`](https://github.com/IonicaBizau/np-init#readme)—Easily start a npm package from scratch. | ||
- [`package-json-path`](https://github.com/IonicaBizau/package-json-path#readme)—Get the package.json path in a specific directory. | ||
- [`packy`](https://github.com/IonicaBizau/packy#readme)—Set default fields in your package.json files. | ||
- [`pm2-meteor`](https://github.com/andruschka/pm2-meteor) (by andruschka)—Simplest way to deploy, scale and run Meteor Apps with PM2. | ||
- [`rucksack`](https://github.com/IonicaBizau/rucksack#readme)—Bundle js files by replacing the require calls in-place. | ||
- [`ssh-remote`](https://github.com/IonicaBizau/ssh-remote)—Automagically switch on the SSH remote url in a Git repository. | ||
- [`statique`](https://github.com/IonicaBizau/node-statique)—A Node.JS static server module with built-in cache options and route features. | ||
- [`tithe`](https://github.com/IonicaBizau/tithe)—Organize and track the tithe payments. | ||
- [`web-term`](https://github.com/IonicaBizau/web-term)—A full screen terminal in your browser. | ||
- [`engine-paths`](https://github.com/jillix/engine-paths#readme) by jillix | ||
## :scroll: License | ||
- [`engine-tools`](https://github.com/jillix/engine-tools) by jillix | ||
- [`fwatcher`](https://github.com/IonicaBizau/node-fwatcher) | ||
- [`gh-notifier`](https://bitbucket.org/IonicaBizau/gh-notifier#readme) | ||
- [`ghcal`](https://github.com/IonicaBizau/ghcal) | ||
- [`git-issues`](https://github.com/softwarescales/git-issues) by Gabriel Petrovay | ||
- [`git-repos`](https://github.com/IonicaBizau/node-git-repos#readme) | ||
- [`git-stats`](https://github.com/IonicaBizau/git-stats) | ||
- [`github-labeller`](https://github.com/IonicaBizau/github-labeller#readme) | ||
- [`gpm`](https://github.com/IonicaBizau/gpm) | ||
- [`idea`](https://github.com/IonicaBizau/idea) | ||
- [`messager`](https://github.com/IonicaBizau/node-messager#readme) | ||
- [`mongof`](https://github.com/IonicaBizau/node-mongof) | ||
- [`namy`](https://github.com/IonicaBizau/namy) | ||
- [`pm2-meteor`](https://github.com/andruschka/pm2-meteor) by andruschka | ||
- [`ssh-remote`](https://github.com/IonicaBizau/ssh-remote) | ||
- [`statique`](https://github.com/IonicaBizau/node-statique) | ||
- [`web-term`](https://github.com/IonicaBizau/web-term) | ||
## License | ||
[MIT][license] © [Ionică Bizău][website] | ||
@@ -97,2 +96,2 @@ | ||
[contributing]: /CONTRIBUTING.md | ||
[docs]: /DOCUMENTATION.md | ||
[docs]: /DOCUMENTATION.md |
11403
33.76%9
12.5%47
2.17%