Comparing version
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.7.1 | ||
// Generated by CoffeeScript 1.8.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var fs, glob, list, path; |
@@ -5,3 +5,3 @@ { | ||
"author": "Awnist <hi@awnist.com> (http://awnist.com)", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"main": "./lib/ls", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -1,7 +0,11 @@ | ||
## What's "ls"? | ||
## What is "ls"? | ||
ls is a node module for cleanly traversing directories and listing files. | ||
`ls` is a node module for cleanly traversing directories and listing files. | ||
The primary goal is a flexible, expressive syntax. | ||
## Installation | ||
$ npm i ls | ||
## Overview | ||
@@ -11,13 +15,18 @@ | ||
ls = require "ls" | ||
var ls = require('ls'); | ||
Then we can be as sparse as | ||
for file in ls "/path" | ||
console.log file.name | ||
for (var file of ls('/path/*')) { | ||
console.log(file.name) | ||
} | ||
Or as elaborate as | ||
Or as elaborate as | ||
ls ["/path/foo*", "/another/path/"], { recurse: true }, /jpg/, -> | ||
console.log @name, "is in", @path, "and is", @stat.size | ||
ls( | ||
'/path/*', | ||
{ recurse: true }, | ||
/jpg/, | ||
file => console.log `${file.name} is in ${$file.path} and is ${file.stat.size}` | ||
) | ||
@@ -28,8 +37,8 @@ ## Usage | ||
ls [path/s], {config}, /file regex/, -> iterator function | ||
ls([path/s], {config}, /file regex/, iteratorFunction) | ||
Each file produces an object with the following parameters: | ||
* full: The path and file (/foo/bar/baz.jpg) | ||
* path: The path to the file (/foo/bar/) | ||
* full: The path and file (/foo/bar/baz.jpg) | ||
* file: The file (baz.jpg) | ||
@@ -41,10 +50,11 @@ * name: The file without an extension (baz) | ||
all_files = ls "/path" | ||
for file in all_files | ||
console.log file.name, "is", file.stat.size | ||
all_files = ls('/path/*') | ||
for (var file of all_files) { | ||
console.log(file.name, 'is', file.stat.size); | ||
} | ||
Or use an iterator function, with the context being the file's object | ||
ls "/path", -> | ||
console.log @name, "is", @stat.size | ||
var prettysize = require('prettysize'); | ||
ls('/tmp/*', file => console.log(`${file.name} is ${prettysize(file.stat.size)}`)); | ||
@@ -54,18 +64,10 @@ The {config} object accepts the following parameters: | ||
* recurse: Should we recurse into directories? (Boolean, default is false) | ||
* type: What kind of files should we return? ("all", "dir", "file", default is "all") | ||
* type: What kind of files should we return? ('all', 'dir', 'file', default is 'all') | ||
The /regex/ will only return matching files. All directories will still be recursed. | ||
The -> iterator function is mostly a style preference, but can be handy if you need to throw an error and stop traversal. | ||
The iterator function is mostly a style preference, but can be handy if you need to throw an error and stop traversal. | ||
## Installation | ||
## License | ||
The recommended way is through the excellent [npm](http://www.npmjs.org/): | ||
$ npm install ls | ||
Otherwise, you can check it in your repository and then expose it: | ||
$ git clone git://github.com/awnist/ls.git node_modules/ls/ | ||
ls is [UNLICENSED](http://unlicense.org/). | ||
ls is [UNLICENSED](http://unlicense.org/). Do whatever you want with it. |
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
70
2.94%5588
-0.87%