ls2json
v0.1.5
Published
create json from a directory
Downloads
12
Readme
ls2json
List files in a directory to JSON string or as a JS object.
From Node
var listAsJSON = require('ls2json');
console.log(listAsJSON(/some/valid/path));
/* returns
{ path: '/Users/Foo/ls2json',
files:
[ { name: '.gitignore',
fullPath: '/Users/Foo/ls2json/.gitignore' },
{ name: '.jshintrc',
fullPath: '/Users/Foo/ls2json/.jshintrc' },
{ name: 'LICENSE',
fullPath: '/Users/Foo/ls2json/LICENSE' },
{ name: 'README.md',
fullPath: '/Users/Foo/ls2json/README.md' },
{ name: 'package.json',
fullPath: '/Users/Foo/ls2json/package.json' } ] }
*/
Command line usage
Usage: ls2json [options]
Options:
-h, --help output usage information
-V, --version output the version number
-d, --dir <path> specify the directory you want to list
-j, --json return a pretty js object rather than a string
Examples:
As a string:
$ ls2json .
'{"path":"/Users/Foo/ls2json","files":[{"name":".gitignore","fullPath":"/Users/Foo/ls2json/.gitignore"},{"name":".jshintrc","fullPath":"/Users/Foo/ls2json/.jshintrc"},{"name":"LICENSE","fullPath":"/Users/Foo/ls2json/LICENSE"},{"name":"README.md","fullPath":"/Users/Foo/ls2json/README.md"},{"name":"package.json","fullPath":"/Users/Foo/ls2json/package.json"}]}'
As an object:
$ ls2json . -j
{ path: '/Users/Foo/ls2json',
files:
[ { name: '.gitignore',
fullPath: '/Users/Foo/ls2json/.gitignore' },
{ name: '.jshintrc',
fullPath: '/Users/Foo/ls2json/.jshintrc' },
{ name: 'LICENSE',
fullPath: '/Users/Foo/ls2json/LICENSE' },
{ name: 'README.md',
fullPath: '/Users/Foo/ls2json/README.md' },
{ name: 'package.json',
fullPath: '/Users/Foo/ls2json/package.json' } ] }