Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bahamas10/node-tilde-expansion
Expand a ~ character to a users home directory like bash
https://github.com/bahamas10/node-tilde-expansion
Last synced: 2 months ago
JSON representation
Expand a ~ character to a users home directory like bash
- Host: GitHub
- URL: https://github.com/bahamas10/node-tilde-expansion
- Owner: bahamas10
- Created: 2012-09-18T01:55:10.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-09-18T01:55:32.000Z (over 12 years ago)
- Last Synced: 2024-10-10T20:16:00.254Z (2 months ago)
- Language: JavaScript
- Size: 93.8 KB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
tilde-expansion
===============Expand a ~ character to a users home directory like bash
Examples
--------Given
``` js
var tilde = require('tilde-expansion');
```You can do basic expansion
``` js
tilde('~root', function(s) {
console.log(s);
});
```yields
```
/root
```or even simpler
``` js
tilde('~/', function(s) {
console.log(s);
});
```yields
```
/home/dave/
```and get fancy with the PWD
``` js
tilde('~+', function(s) {
console.log(s);
});
```yields
```
/home/dave/dev
```Notes
------ Any unrecognized expansions will result in the string being unchanged
- The node [etc-passwd](https://github.com/bahamas10/node-etc-passwd) module is
used to determine the home directory of a user
- If the user is not found on the system, the expansion will remain unaltered
- The string must be unquoted for any expansion to take place (see bash(1))Usage
-----``` js
var tilde = require('tilde-expansion');
```Installation
------------npm install tilde-expansion
Tests
-----npm test
License
-------MIT License