diff options
Diffstat (limited to 'cordova/node_modules/tail')
| -rwxr-xr-x | cordova/node_modules/tail/README.md | 72 | ||||
| -rwxr-xr-x | cordova/node_modules/tail/package.json | 61 | ||||
| -rwxr-xr-x | cordova/node_modules/tail/tail.js | 147 |
3 files changed, 0 insertions, 280 deletions
diff --git a/cordova/node_modules/tail/README.md b/cordova/node_modules/tail/README.md deleted file mode 100755 index eec282c..0000000 --- a/cordova/node_modules/tail/README.md +++ /dev/null @@ -1,72 +0,0 @@ -#tail - -To install: - -```bash -npm install tail -``` - -#Use: -```javascript -Tail = require('tail').Tail; - -tail = new Tail("fileToTail"); - -tail.on("line", function(data) { - console.log(data); -}); - -tail.on("error", function(error) { - console.log('ERROR: ', error); -}); -```` - -Tail constructor accepts few parameters: - -```javascript - -var fileToTail = "/path/to/fileToTail.txt"; -var lineSeparator= "\n"; -var fromBeginning = false; -var watchOptions = {}; \\ as per node fs.watch documentations - -new Tail(fileToTail, lineSeparator, watchOptions,fromBeginning) -``` - -* `fileToTail` is the name (inclusive of the path) of the file to tail -* `lineSeparator` is the line separator token (default "\n") -* `watchOptions` is the full set of options that can be passed to `fs.watch` as per node documentation (default: {}) -* `fromBeginning` force the tail of the file from the very beginning of it instead of from the first new line that will be appended(default: "\n") - -The only mandatory one is the first, i.e. the the file you want to tail. - -Tail emits two type of events: - -* line -``` -function(data){} -``` -* error -``` -function(exception){} -``` - -If you simply want to stop the tail: - -```javascript -tail.unwatch() -``` - -And to start watching again: -```javascript -tail.watch() -``` - -#Want to fork ? - -Tail is written in [CoffeeScript](http://jashkenas.github.com/coffee-script/). - -The Cakefile generates the javascript that is then published to npm. - -#License -MIT. Please see License file for more details. diff --git a/cordova/node_modules/tail/package.json b/cordova/node_modules/tail/package.json deleted file mode 100755 index 73add18..0000000 --- a/cordova/node_modules/tail/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "_from": "tail@^0.4.0", - "_id": "[email protected]", - "_inBundle": true, - "_integrity": "sha1-0p3nJ1DMmdseBTr/E8NZ7PtxMAI=", - "_location": "/cordova-ios/tail", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "tail@^0.4.0", - "name": "tail", - "escapedName": "tail", - "rawSpec": "^0.4.0", - "saveSpec": null, - "fetchSpec": "^0.4.0" - }, - "_requiredBy": [ - "/cordova-ios", - "/cordova-ios/simctl" - ], - "_resolved": "https://registry.npmjs.org/tail/-/tail-0.4.0.tgz", - "_shasum": "d29de72750cc99db1e053aff13c359ecfb713002", - "_spec": "tail@^0.4.0", - "_where": "/Users/brodybits/Documents/cordova/cordova-ios/node_modules/simctl", - "author": { - "name": "Luca Grulla" - }, - "bugs": { - "url": "https://github.com/lucagrulla/node-tail/issues" - }, - "bundleDependencies": false, - "contributors": [ - { - "name": "Luca Grulla" - }, - { - "name": "Tom Hall" - }, - { - "name": "Andy Kent" - } - ], - "dependencies": {}, - "deprecated": false, - "description": "tail a file in node", - "devDependencies": { - "coffee-script": "1.7.1" - }, - "engines": { - "node": ">= 0.4.0" - }, - "homepage": "https://github.com/lucagrulla/node-tail#readme", - "main": "tail", - "name": "tail", - "repository": { - "type": "git", - "url": "git://github.com/lucagrulla/node-tail.git" - }, - "version": "0.4.0" -} diff --git a/cordova/node_modules/tail/tail.js b/cordova/node_modules/tail/tail.js deleted file mode 100755 index 061ceab..0000000 --- a/cordova/node_modules/tail/tail.js +++ /dev/null @@ -1,147 +0,0 @@ -// Generated by CoffeeScript 1.6.2 -var Tail, environment, events, fs, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; - -events = require("events"); - -fs = require('fs'); - -environment = process.env['NODE_ENV'] || 'development'; - -Tail = (function(_super) { - __extends(Tail, _super); - - Tail.prototype.readBlock = function() { - var block, stream, - _this = this; - - if (this.queue.length >= 1) { - block = this.queue.shift(); - if (block.end > block.start) { - stream = fs.createReadStream(this.filename, { - start: block.start, - end: block.end - 1, - encoding: "utf-8" - }); - stream.on('error', function(error) { - console.log("Tail error:" + error); - return _this.emit('error', error); - }); - stream.on('end', function() { - if (_this.queue.length >= 1) { - return _this.internalDispatcher.emit("next"); - } - }); - return stream.on('data', function(data) { - var chunk, parts, _i, _len, _results; - - _this.buffer += data; - parts = _this.buffer.split(_this.separator); - _this.buffer = parts.pop(); - _results = []; - for (_i = 0, _len = parts.length; _i < _len; _i++) { - chunk = parts[_i]; - _results.push(_this.emit("line", chunk)); - } - return _results; - }); - } - } - }; - - function Tail(filename, separator, fsWatchOptions, frombeginning) { - var stats, - _this = this; - - this.filename = filename; - this.separator = separator != null ? separator : '\n'; - this.fsWatchOptions = fsWatchOptions != null ? fsWatchOptions : {}; - this.frombeginning = frombeginning != null ? frombeginning : false; - this.readBlock = __bind(this.readBlock, this); - this.buffer = ''; - this.internalDispatcher = new events.EventEmitter(); - this.queue = []; - this.isWatching = false; - stats = fs.statSync(this.filename); - this.internalDispatcher.on('next', function() { - return _this.readBlock(); - }); - this.pos = this.frombeginning ? 0 : stats.size; - this.watch(); - } - - Tail.prototype.watch = function() { - var _this = this; - - if (this.isWatching) { - return; - } - this.isWatching = true; - if (fs.watch) { - return this.watcher = fs.watch(this.filename, this.fsWatchOptions, function(e) { - return _this.watchEvent(e); - }); - } else { - return fs.watchFile(this.filename, this.fsWatchOptions, function(curr, prev) { - return _this.watchFileEvent(curr, prev); - }); - } - }; - - Tail.prototype.watchEvent = function(e) { - var stats, - _this = this; - - if (e === 'change') { - stats = fs.statSync(this.filename); - if (stats.size < this.pos) { - this.pos = stats.size; - } - if (stats.size > this.pos) { - this.queue.push({ - start: this.pos, - end: stats.size - }); - this.pos = stats.size; - if (this.queue.length === 1) { - return this.internalDispatcher.emit("next"); - } - } - } else if (e === 'rename') { - this.unwatch(); - return setTimeout((function() { - return _this.watch(); - }), 1000); - } - }; - - Tail.prototype.watchFileEvent = function(curr, prev) { - if (curr.size > prev.size) { - this.queue.push({ - start: prev.size, - end: curr.size - }); - if (this.queue.length === 1) { - return this.internalDispatcher.emit("next"); - } - } - }; - - Tail.prototype.unwatch = function() { - if (fs.watch && this.watcher) { - this.watcher.close(); - this.pos = 0; - } else { - fs.unwatchFile(this.filename); - } - this.isWatching = false; - return this.queue = []; - }; - - return Tail; - -})(events.EventEmitter); - -exports.Tail = Tail; |
