0.1.8 • Published 11 years ago

file-picker v0.1.8

Weekly downloads
3
License
-
Repository
github
Last release
11 years ago

install

npm install file-picker

api

  • pick(string target_directory, [array pick_types], function callback) - array pick_types is array of file extension formats (ex . ['.py', '.js']) - function callback is return array of files infomation - { string path, string relative_path, string base, string relative_base, name, extension }
  • object treefy(array files) picked files information to tree structure

pick files at a directory

{pick} = require('file-picker')

pick '~/some_directory', ['.as'], (files) ->
	console.log(files)
	

print on console

[ { path: '/Users/ssen/Data/workspace/SrcViewer/src/SrcViewer.mxml',
    relative_path: 'src/SrcViewer.mxml',
    base: '/Users/ssen/Data/workspace/SrcViewer/src',
    relative_base: 'src',
    name: 'SrcViewer',
    extension: '.mxml' },
  { path: '/Users/ssen/Data/workspace/SrcViewer/src/ssen/airkit/update/AIRUpdate.as',
    relative_path: 'src/ssen/airkit/update/AIRUpdate.as',
    base: '/Users/ssen/Data/workspace/SrcViewer/src/ssen/airkit/update',
    relative_base: 'src/ssen/airkit/update',
    name: 'AIRUpdate',
    extension: '.as' },
  { path: '/Users/ssen/Data/workspace/SrcViewer/src/ssen/airkit/update/AIRUpdateError.as',
    relative_path: 'src/ssen/airkit/update/AIRUpdateError.as',
    base: '/Users/ssen/Data/workspace/SrcViewer/src/ssen/airkit/update',
    relative_base: 'src/ssen/airkit/update',
    name: 'AIRUpdateError',
    extension: '.as' },
  ....
  

files to tree object

util = require('util')
{pick, treefy} = require('file-picker')

pick '~/some_directory', ['.as'], (files) ->
	console.log(util.inspect(treefy(files)))
	

print

{ssen : {
	airkit : {
		update : {
			AIRUpdate : 1, // index of files array 
			AIRUpdateError : 2
...
0.1.8

11 years ago

0.1.7

11 years ago

0.1.6

11 years ago

0.1.5

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago