UNPKG

bricks-cli

Version:

Command line tool for developing ambitious ember.js apps

46 lines (45 loc) 3.81 kB
{ "author": { "name": "Filirom1", "email": "filirom1@gmail.com" }, "name": "findup", "description": "Walk up ancester's dir up to root", "version": "0.1.5", "repository": { "type": "git", "url": "https://github.com/Filirom1/findup.git" }, "bin": { "findup": "bin/findup.js" }, "scripts": { "test": "mocha ./test/*.js" }, "dependencies": { "colors": "~0.6.0-1", "commander": "~2.1.0" }, "devDependencies": { "mocha": "~1.3.0", "chai": "~1.1.1" }, "optionalDependencies": {}, "engines": { "node": ">=0.6" }, "licenses": [ { "type": "MIT", "url": "http : //www.opensource.org/licenses/MIT" } ], "readme": "[![build status](https://secure.travis-ci.org/Filirom1/findup.png)](http://travis-ci.org/Filirom1/findup)\nFind-up\n=======\n\n### Install\n\n npm install -g findup\n\n### Usage\n\nFind up a file in ancestor's dir\n\n\n .\n ├── config.json\n └── f\n └── e\n └── d\n └── c\n ├── b\n │   └── a\n └── config.json\n\n#### Async\n\nfindup(dir, fileName, callback)\nfindup(dir, iterator, callback) with `iterator(dir, cb)` where cb only accept `true` or `false`\n\n var findup = require('findup');\n\n\n findup(__dirname + '/f/e/d/c/b/a', 'config.json', function(err, dir){\n // if(e) e === new Error('not found')\n // dir === '/f/e/d/c'\n });\n\nor\n\n findup(__dirname + '/f/e/d/c/b/a', function(dir, cb){\n require('path').exists(dir + '/config.json', cb);\n }, function(err, dir){\n // if(e) e === new Error('not found')\n // dir === '/f/e/d/c'\n });\n\n\n#### EventEmitter\n\nfindup(dir, fileName)\n\n var findup = require('findup');\n var fup = findup(__dirname + '/f/e/d/c/b/a', 'config.json');\n\nfindup(dir, iterator) with `iterator(dir, cb)` where cb only accept `true` or `false`\n\n var findup = require('findup');\n var fup = findup(__dirname + '/f/e/d/c/b/a', function(dir, cb){\n require('path').exists(dir + '/config.json', cb);\n });\n\nfindup return an EventEmitter. 3 events are emitted: `found`, `error`, `end`\n\n`found` event is emitted each time a file is found.\n\nYou can stop the traversing by calling `stop` manually.\n\n fup.on('found', function(dir){\n // dir === '/f/e/d/c'\n fup.stop();\n });\n\n`error` event is emitted when error happens\n\n fup.on('error', function(e){\n // if(e) e === new Error('not found')\n });\n\n`end` event is emitted at the end of the traversing or after `stop()` is\ncalled.\n\n fup.on('end', function(){\n // happy end\n });\n\n#### Sync\n\nfindup(dir, fileName)\nfindup(dir, iteratorSync) with `iteratorSync` return `true` or `false`\n\n var findup = require('findup');\n\n try{\n var dir = findup.sync(__dirname + '/f/e/d/c/b/a', 'config.json'); // dir === '/f/e/d/c'\n }catch(e){\n // if(e) e === new Error('not found')\n }\n\n#### CLI\n\n npm install -g findup\n\n $ cd test/fixture/f/e/d/c/b/a/\n $ findup package.json\n /root/findup/package.json\n\nUsage\n\n $ findup -h\n\n Usage: findup [FILE]\n\n --name, -n The name of the file to found\n --dir, -d The directoy where we will start walking up $PWD\n --help, -h show usage false\n --verbose, -v print log false\n\n### LICENSE MIT\n\n### Read the tests :)\n", "readmeFilename": "README.md", "bugs": { "url": "https://github.com/Filirom1/findup/issues" }, "homepage": "https://github.com/Filirom1/findup", "_id": "findup@0.1.5", "_from": "findup@^0.1.5" }