...
 
Commits (5)
.DS_Store
*.log
node_modules
build
*.node
components
coverage
*.orig
.idea
sandbox
test/out-fixtures/*
test/watch-*.txt
gulp.1
node-gulp (3.9.1-7) UNRELEASED; urgency=medium
node-gulp (3.9.1-7) unstable; urgency=medium
* Team upload
......@@ -15,8 +15,13 @@ node-gulp (3.9.1-7) UNRELEASED; urgency=medium
* Update debian/copyright
* Update VCS fields to salsa
* Add desc in patches
* Remove upstream .gitignore
* Install outdated needed components: first-chunk-stream, gaze,
glob-watcher, is-utf8, strip-bom, vinyl and vinyl-fs (Closes: #894962)
* Add node-defaults and node-globule in dependencies
* Use pkg-js-tools for tests
-- Xavier Guimard <yadd@debian.org> Mon, 11 Feb 2019 21:34:19 +0100
-- Xavier Guimard <yadd@debian.org> Mon, 11 Feb 2019 22:09:28 +0100
node-gulp (3.9.1-6) unstable; urgency=medium
......
......@@ -2,6 +2,7 @@ Source: node-gulp
Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@lists.alioth.debian.org>
Uploaders: Pirate Praveen <praveen@debian.org>
Section: javascript
Testsuite: autopkgtest-pkg-nodejs
Priority: optional
Build-Depends: debhelper (>= 11~),
dh-buildinfo,
......@@ -9,7 +10,9 @@ Build-Depends: debhelper (>= 11~),
nodejs,
node-archy,
node-chalk,
node-defaults,
node-deprecated,
node-globule,
node-gulp-util,
node-interpret,
node-liftoff,
......@@ -23,7 +26,8 @@ Build-Depends: debhelper (>= 11~),
node-should,
node-tildify,
node-v8flags,
node-vinyl-fs
node-vinyl-fs,
pkg-js-tools
Standards-Version: 4.3.0
Vcs-Browser: https://salsa.debian.org/js-team/node-gulp
Vcs-Git: https://salsa.debian.org/js-team/node-gulp.git
......@@ -35,7 +39,9 @@ Depends: ${misc:Depends},
nodejs,
node-archy,
node-chalk,
node-defaults,
node-deprecated,
node-globule,
node-gulp-util,
node-interpret,
node-liftoff,
......
......@@ -18,6 +18,14 @@ Copyright: 2016 Pirate Praveen <praveen@debian.org>
2019, Xavier Guimard <yadd@debian.org>
License: Expat
Files: debian/node_modules/is-utf8/*
Copyright: 2014, Wei Fanzhe
License: Expat
Files: debian/node_modules/vinyl/node_modules/clone/*
Copyright: 2011-2014, Paul Vorbach <paul@vorba.ch>
License: Expat
License: Expat
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
......
[import-orig]
filter = .gitignore
......@@ -4,3 +4,4 @@ completion usr/lib/nodejs/gulp/
index.js usr/lib/nodejs/gulp/
lib usr/lib/nodejs/gulp/
package.json usr/lib/nodejs/gulp/
debian/node_modules usr/lib/nodejs/gulp/
'use strict';
var util = require('util');
var Transform = require('stream').Transform;
function ctor(options, transform) {
util.inherits(FirstChunk, Transform);
if (typeof options === 'function') {
transform = options;
options = {};
}
if (typeof transform !== 'function') {
throw new Error('transform function required');
}
function FirstChunk(options2) {
if (!(this instanceof FirstChunk)) {
return new FirstChunk(options2);
}
Transform.call(this, options2);
this._firstChunk = true;
this._transformCalled = false;
this._minSize = options.minSize;
}
FirstChunk.prototype._transform = function (chunk, enc, cb) {
this._enc = enc;
if (this._firstChunk) {
this._firstChunk = false;
if (this._minSize == null) {
transform.call(this, chunk, enc, cb);
this._transformCalled = true;
return;
}
this._buffer = chunk;
cb();
return;
}
if (this._minSize == null) {
this.push(chunk);
cb();
return;
}
if (this._buffer.length < this._minSize) {
this._buffer = Buffer.concat([this._buffer, chunk]);
cb();
return;
}
if (this._buffer.length >= this._minSize) {
transform.call(this, this._buffer.slice(), enc, function () {
this.push(chunk);
cb();
}.bind(this));
this._transformCalled = true;
this._buffer = false;
return;
}
this.push(chunk);
cb();
};
FirstChunk.prototype._flush = function (cb) {
if (!this._buffer) {
cb();
return;
}
if (this._transformCalled) {
this.push(this._buffer);
cb();
} else {
transform.call(this, this._buffer.slice(), this._enc, cb);
}
};
return FirstChunk;
}
module.exports = function () {
return ctor.apply(ctor, arguments)();
};
module.exports.ctor = ctor;
{
"_from": "first-chunk-stream@^1.0.0",
"_id": "first-chunk-stream@1.0.0",
"_inBundle": false,
"_integrity": "sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=",
"_location": "/first-chunk-stream",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "first-chunk-stream@^1.0.0",
"name": "first-chunk-stream",
"escapedName": "first-chunk-stream",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/strip-bom"
],
"_resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz",
"_shasum": "59bfb50cd905f60d7c394cd3d9acaab4e6ad934e",
"_spec": "first-chunk-stream@^1.0.0",
"_where": "/tmp/tt/node_modules/strip-bom",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/first-chunk-stream/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Transform the first chunk in a stream",
"devDependencies": {
"concat-stream": "^1.4.5",
"mocha": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/first-chunk-stream#readme",
"keywords": [
"buffer",
"stream",
"streams",
"transform",
"first",
"chunk",
"size",
"min",
"minimum"
],
"license": "MIT",
"name": "first-chunk-stream",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/first-chunk-stream.git"
},
"scripts": {
"test": "mocha"
},
"version": "1.0.0"
}
# first-chunk-stream [![Build Status](https://travis-ci.org/sindresorhus/first-chunk-stream.svg?branch=master)](https://travis-ci.org/sindresorhus/first-chunk-stream)
> Transform the first chunk in a stream
Useful if you want to do something to the first chunk.
You can also set the minimum size of that chunk.
## Install
```sh
$ npm install --save first-chunk-stream
```
## Usage
```js
var fs = require('fs');
var concat = require('concat-stream');
var firstChunk = require('first-chunk-stream');
// unicorn.txt => unicorn rainbow
// `highWaterMark: 1` means it will only read 1 byte at the time
fs.createReadStream('unicorn.txt', {highWaterMark: 1})
.pipe(firstChunk({minSize: 7}, function (chunk, enc, cb) {
this.push(chunk.toUpperCase());
cb();
}))
.pipe(concat(function (data) {
console.log(data);
//=> UNICORN rainbow
}));
```
## API
### firstChunk([options], transform)
#### options.minSize
Type: `number`
The minimum size of the first chunk.
#### transform(chunk, encoding, callback)
*Required*
Type: `function`
The [function](http://nodejs.org/docs/latest/api/stream.html#stream_transform_transform_chunk_encoding_callback) that gets the first chunk.
### firstChunk.ctor()
Instead of returning a [stream.Transform](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_transform_1) instance, `firstChunk.ctor()` returns a constructor for a custom Transform. This is useful when you want to use the same transform logic in multiple instances.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
Copyright (c) 2013 Kyle Robinson Young
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
# gaze [![Build Status](https://travis-ci.org/shama/gaze.png?branch=master)](https://travis-ci.org/shama/gaze)
A globbing fs.watch wrapper built from the best parts of other fine watch libs.
Compatible with Node.js 0.10/0.8, Windows, OSX and Linux.
![gaze](http://dontkry.com/images/repos/gaze.png)
## Usage
Install the module with: `npm install gaze` or place into your `package.json`
and run `npm install`.
```javascript
var gaze = require('gaze');
// Watch all .js files/dirs in process.cwd()
gaze('**/*.js', function(err, watcher) {
// Files have all started watching
// watcher === this
// Get all watched files
console.log(this.watched());
// On file changed
this.on('changed', function(filepath) {
console.log(filepath + ' was changed');
});
// On file added
this.on('added', function(filepath) {
console.log(filepath + ' was added');
});
// On file deleted
this.on('deleted', function(filepath) {
console.log(filepath + ' was deleted');
});
// On changed/added/deleted
this.on('all', function(event, filepath) {
console.log(filepath + ' was ' + event);
});
// Get watched files with relative paths
console.log(this.relative());
});
// Also accepts an array of patterns
gaze(['stylesheets/*.css', 'images/**/*.png'], function() {
// Add more patterns later to be watched
this.add(['js/*.js']);
});
```
### Alternate Interface
```javascript
var Gaze = require('gaze').Gaze;
var gaze = new Gaze('**/*');
// Files have all started watching
gaze.on('ready', function(watcher) { });
// A file has been added/changed/deleted has occurred
gaze.on('all', function(event, filepath) { });
```
### Errors
```javascript
gaze('**/*', function() {
this.on('error', function(err) {
// Handle error here
});
});
```
### Minimatch / Glob
See [isaacs's minimatch](https://github.com/isaacs/minimatch) for more
information on glob patterns.
## Documentation
### gaze(patterns, [options], callback)
* `patterns` {String|Array} File patterns to be matched
* `options` {Object}
* `callback` {Function}
* `err` {Error | null}
* `watcher` {Object} Instance of the Gaze watcher
### Class: gaze.Gaze
Create a Gaze object by instanting the `gaze.Gaze` class.
```javascript
var Gaze = require('gaze').Gaze;
var gaze = new Gaze(pattern, options, callback);
```
#### Properties
* `options` The options object passed in.
* `interval` {integer} Interval to pass to fs.watchFile
* `debounceDelay` {integer} Delay for events called in succession for the same
file/event
#### Events
* `ready(watcher)` When files have been globbed and watching has begun.
* `all(event, filepath)` When an `added`, `changed` or `deleted` event occurs.
* `added(filepath)` When a file has been added to a watch directory.
* `changed(filepath)` When a file has been changed.
* `deleted(filepath)` When a file has been deleted.
* `renamed(newPath, oldPath)` When a file has been renamed.
* `end()` When the watcher is closed and watches have been removed.
* `error(err)` When an error occurs.
* `nomatch` When no files have been matched.
#### Methods
* `emit(event, [...])` Wrapper for the EventEmitter.emit.
`added`|`changed`|`deleted` events will also trigger the `all` event.
* `close()` Unwatch all files and reset the watch instance.
* `add(patterns, callback)` Adds file(s) patterns to be watched.
* `remove(filepath)` removes a file or directory from being watched. Does not
recurse directories.
* `watched()` Returns the currently watched files.
* `relative([dir, unixify])` Returns the currently watched files with relative paths.
* `dir` {string} Only return relative files for this directory.
* `unixify` {boolean} Return paths with `/` instead of `\\` if on Windows.
## FAQs
### Why Another `fs.watch` Wrapper?
I liked parts of other `fs.watch` wrappers but none had all the features I
needed. This lib combines the features I needed from other fine watch libs:
Speedy data behavior from
[paulmillr's chokidar](https://github.com/paulmillr/chokidar), API interface
from [mikeal's watch](https://github.com/mikeal/watch) and file globbing using
[isaacs's glob](https://github.com/isaacs/node-glob) which is also used by
[cowboy's Grunt](https://github.com/gruntjs/grunt).
### How do I fix the error `EMFILE: Too many opened files.`?
This is because of your system's max opened file limit. For OSX the default is
very low (256). Increase your limit temporarily with `ulimit -n 10480`, the
number being the new max limit.
## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style.
Add unit tests for any new or changed functionality. Lint and test your code
using [grunt](http://gruntjs.com/).
## Release History
* 0.5.2 - Fix for ENOENT error with non-existent symlinks.
* 0.5.1 - Use setImmediate (process.nextTick for node v0.8) to defer ready/nomatch events (@amasad).
* 0.5.0 - Process is now kept alive while watching files. Emits a nomatch event when no files are matching.
* 0.4.3 - Track file additions in newly created folders (@brett-shwom).
* 0.4.2 - Fix .remove() method to remove a single file in a directory (@kaelzhang). Fixing Cannot call method 'call' of undefined (@krasimir). Track new file additions within folders (@brett-shwom).
* 0.4.1 - Fix watchDir not respecting close in race condition (@chrisirhc).
* 0.4.0 - Drop support for node v0.6. Use globule for file matching. Avoid node v0.10 path.resolve/join errors. Register new files when added to non-existent folder. Multiple instances can now poll the same files (@jpommerening).
* 0.3.4 - Code clean up. Fix path must be strings errors (@groner). Fix incorrect added events (@groner).
* 0.3.3 - Fix for multiple patterns with negate.
* 0.3.2 - Emit `end` before removeAllListeners.
* 0.3.1 - Fix added events within subfolder patterns.
* 0.3.0 - Handle safewrite events, `forceWatchMethod` option removed, bug fixes and watch optimizations (@rgaskill).
* 0.2.2 - Fix issue where subsequent add calls dont get watched (@samcday). removeAllListeners on close.
* 0.2.1 - Fix issue with invalid `added` events in current working dir.
* 0.2.0 - Support and mark folders with `path.sep`. Add `forceWatchMethod` option. Support `renamed` events.
* 0.1.6 - Recognize the `cwd` option properly
* 0.1.5 - Catch too many open file errors
* 0.1.4 - Really fix the race condition with 2 watches
* 0.1.3 - Fix race condition with 2 watches
* 0.1.2 - Read triggering changed event fix
* 0.1.1 - Minor fixes
* 0.1.0 - Initial release
## License
Copyright (c) 2013 Kyle Robinson Young
Licensed under the MIT license.
This diff is collapsed.
'use strict';
var path = require('path');
var helper = module.exports = {};
// Returns boolean whether filepath is dir terminated
helper.isDir = function isDir(dir) {
if (typeof dir !== 'string') { return false; }
return (dir.slice(-(path.sep.length)) === path.sep);
};
// Create a `key:[]` if doesnt exist on `obj` then push or concat the `val`
helper.objectPush = function objectPush(obj, key, val) {
if (obj[key] == null) { obj[key] = []; }
if (Array.isArray(val)) { obj[key] = obj[key].concat(val); }
else if (val) { obj[key].push(val); }
return obj[key] = helper.unique(obj[key]);
};
// Ensures the dir is marked with path.sep
helper.markDir = function markDir(dir) {
if (typeof dir === 'string' &&
dir.slice(-(path.sep.length)) !== path.sep &&
dir !== '.') {
dir += path.sep;
}
return dir;
};
// Changes path.sep to unix ones for testing
helper.unixifyPathSep = function unixifyPathSep(filepath) {
return (process.platform === 'win32') ? String(filepath).replace(/\\/g, '/') : filepath;
};
/**
* Lo-Dash 1.0.1 <http://lodash.com/>
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.4.4 <http://underscorejs.org/>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud Inc.
* Available under MIT license <http://lodash.com/license>
*/
helper.unique = function unique() { var array = Array.prototype.concat.apply(Array.prototype, arguments); var result = []; for (var i = 0; i < array.length; i++) { if (result.indexOf(array[i]) === -1) { result.push(array[i]); } } return result; };
/**
* Copyright (c) 2010 Caolan McMahon
* Available under MIT license <https://raw.github.com/caolan/async/master/LICENSE>
*/
helper.forEachSeries = function forEachSeries(arr, iterator, callback) {
if (!arr.length) { return callback(); }
var completed = 0;
var iterate = function() {
iterator(arr[completed], function (err) {
if (err) {
callback(err);
callback = function() {};
} else {
completed += 1;
if (completed === arr.length) {
callback(null);
} else {
iterate();
}
}
});
};
iterate();
};
{
"_from": "gaze@^0.5.1",
"_id": "gaze@0.5.2",
"_inBundle": false,
"_integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=",
"_location": "/gaze",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "gaze@^0.5.1",
"name": "gaze",
"escapedName": "gaze",
"rawSpec": "^0.5.1",
"saveSpec": null,
"fetchSpec": "^0.5.1"
},
"_requiredBy": [
"/glob-watcher"
],
"_resolved": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz",
"_shasum": "40b709537d24d1d45767db5a908689dfe69ac44f",
"_spec": "gaze@^0.5.1",
"_where": "/tmp/tt/node_modules/glob-watcher",
"author": {
"name": "Kyle Robinson Young",
"email": "kyle@dontkry.com"
},
"bugs": {
"url": "https://github.com/shama/gaze/issues"
},
"bundleDependencies": false,
"dependencies": {
"globule": "~0.1.0"
},
"deprecated": false,
"description": "A globbing fs.watch wrapper built from the best parts of other fine watch libs.",
"devDependencies": {
"async": "~0.2.10",
"grunt": "~0.4.1",
"grunt-benchmark": "~0.2.0",
"grunt-cli": "~0.1.13",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-nodeunit": "~0.2.0",
"rimraf": "~2.2.6"
},
"engines": {
"node": ">= 0.8.0"
},
"files": [
"lib",
"LICENSE-MIT"
],
"homepage": "https://github.com/shama/gaze",
"keywords": [
"watch",
"glob"
],
"licenses": [
{
"type": "MIT",
"url": "https://github.com/shama/gaze/blob/master/LICENSE-MIT"
}
],
"main": "lib/gaze",
"name": "gaze",
"repository": {
"type": "git",
"url": "git://github.com/shama/gaze.git"
},
"scripts": {
"test": "grunt nodeunit -v"
},
"version": "0.5.2"
}
language: node_js
node_js:
- "0.9"
- "0.10"
after_script:
- npm run coveralls
\ No newline at end of file
# glob-watcher [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Dependency Status][david-image]][david-url]
## Information
<table>
<tr>
<td>Package</td><td>glob-watcher</td>
</tr>
<tr>
<td>Description</td>
<td>Watch globs</td>
</tr>
<tr>
<td>Node Version</td>
<td>>= 0.9</td>
</tr>
</table>
## Usage
```javascript
var watch = require('glob-watcher');
// callback interface
watch(["./*.js", "!./something.js"], function(evt){
// evt has what file changed and all that jazz
});
// EE interface
var watcher = watch(["./*.js", "!./something.js"]);
watcher.on('change', function(evt) {
// evt has what file changed and all that jazz
});
// add files after it has been created
watcher.add("./somefolder/somefile.js");
```
[npm-url]: https://npmjs.org/package/glob-watcher
[npm-image]: https://badge.fury.io/js/glob-watcher.png
[travis-url]: https://travis-ci.org/wearefractal/glob-watcher
[travis-image]: https://travis-ci.org/wearefractal/glob-watcher.png?branch=master
[coveralls-url]: https://coveralls.io/r/wearefractal/glob-watcher
[coveralls-image]: https://coveralls.io/repos/wearefractal/glob-watcher/badge.png
[depstat-url]: https://david-dm.org/wearefractal/glob-watcher
[depstat-image]: https://david-dm.org/wearefractal/glob-watcher.png
[david-url]: https://david-dm.org/wearefractal/glob-watcher
[david-image]: https://david-dm.org/wearefractal/glob-watcher.png?theme=shields.io
var gaze = require('gaze');
var EventEmitter = require('events').EventEmitter;
module.exports = function(glob, opts, cb) {
var out = new EventEmitter();
if (typeof opts === 'function') {
cb = opts;
opts = {};
}
var watcher = gaze(glob, opts, function(err, rwatcher){
if (err) out.emit('error', err);
rwatcher.on('all', function(evt, path, old){
var outEvt = {type: evt, path: path};
if(old) outEvt.old = old;
out.emit('change', outEvt);
if(cb) cb(outEvt);
});
});
watcher.on('end', out.emit.bind(out, 'end'));
watcher.on('error', out.emit.bind(out, 'error'));
watcher.on('ready', out.emit.bind(out, 'ready'));
watcher.on('nomatch', out.emit.bind(out, 'nomatch'));
out.end = function(){
return watcher.close();
};
out.add = function(){
return watcher.add.apply(watcher, arguments);
};
out.remove = function(){
return watcher.remove();
};
out._watcher = watcher;
return out;
};
{
"_from": "glob-watcher@^0.0.6",
"_id": "glob-watcher@0.0.6",
"_inBundle": false,
"_integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=",
"_location": "/glob-watcher",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "glob-watcher@^0.0.6",
"name": "glob-watcher",
"escapedName": "glob-watcher",
"rawSpec": "^0.0.6",
"saveSpec": null,
"fetchSpec": "^0.0.6"
},
"_requiredBy": [
"/vinyl-fs"
],
"_resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz",
"_shasum": "b95b4a8df74b39c83298b0c05c978b4d9a3b710b",
"_spec": "glob-watcher@^0.0.6",
"_where": "/tmp/tt/node_modules/vinyl-fs",
"author": {
"name": "Fractal",
"email": "contact@wearefractal.com",
"url": "http://wearefractal.com/"
},
"bugs": {
"url": "https://github.com/wearefractal/glob-watcher/issues"
},
"bundleDependencies": false,
"dependencies": {
"gaze": "^0.5.1"
},
"deprecated": false,
"description": "Watch globs",
"devDependencies": {
"coveralls": "^2.6.1",
"istanbul": "^0.2.3",
"jshint": "^2.4.1",
"mkdirp": "^0.3.5",
"mocha": "^1.17.0",
"mocha-lcov-reporter": "0.0.1",
"rimraf": "^2.2.5",
"should": "^2.1.1"
},
"engines": {
"node": ">= 0.9"
},
"homepage": "http://github.com/wearefractal/glob-watcher",
"licenses": [
{
"type": "MIT",
"url": "http://github.com/wearefractal/glob-watcher/raw/master/LICENSE"
}
],
"main": "./index.js",
"name": "glob-watcher",
"repository": {
"type": "git",
"url": "git://github.com/wearefractal/glob-watcher.git"
},
"scripts": {
"coveralls": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
"test": "mocha --reporter spec && jshint"
},
"version": "0.0.6"
}
var watch = require('../');
var should = require('should');
var path = require('path');
var fs = require('fs');
var rimraf = require('rimraf');
var mkdirp = require('mkdirp');
require('mocha');
describe('glob-watcher', function() {
it('should return a valid file struct via EE', function(done) {
var expectedName = path.join(__dirname, "./fixtures/stuff/temp.coffee");
var fname = path.join(__dirname, "./fixtures/**/temp.coffee");
mkdirp.sync(path.dirname(expectedName));
fs.writeFileSync(expectedName, "testing");
var watcher = watch(fname);
watcher.on('change', function(evt) {
should.exist(evt);
should.exist(evt.path);
should.exist(evt.type);
evt.type.should.equal('changed');
evt.path.should.equal(expectedName);
watcher.end();
});
watcher.on('end', function(){
rimraf.sync(expectedName);
done();
});
setTimeout(function(){
fs.writeFileSync(expectedName, "test test");
}, 125);
});
it('should emit nomatch via EE', function(done) {
var fname = path.join(__dirname, "./doesnt_exist_lol/temp.coffee");
var watcher = watch(fname);
watcher.on('nomatch', function() {
done();
});
});
it('should return a valid file struct via callback', function(done) {
var expectedName = path.join(__dirname, "./fixtures/stuff/test.coffee");
var fname = path.join(__dirname, "./fixtures/**/test.coffee");
mkdirp.sync(path.dirname(expectedName));
fs.writeFileSync(expectedName, "testing");
var watcher = watch(fname, function(evt) {
should.exist(evt);
should.exist(evt.path);
should.exist(evt.type);
evt.type.should.equal('changed');
evt.path.should.equal(expectedName);
watcher.end();
});
watcher.on('end', function(){
rimraf.sync(expectedName);
done();
});
setTimeout(function(){
fs.writeFileSync(expectedName, "test test");
}, 200);
});
it('should not return a non-matching file struct via callback', function(done) {
var expectedName = path.join(__dirname, "./fixtures/test123.coffee");
var fname = path.join(__dirname, "./fixtures/**/test.coffee");
mkdirp.sync(path.dirname(expectedName));
fs.writeFileSync(expectedName, "testing");
var watcher = watch(fname, function(evt) {
throw new Error("Should not have been called! "+evt.path);
});
setTimeout(function(){
fs.writeFileSync(expectedName, "test test");
}, 200);
setTimeout(function(){
rimraf.sync(expectedName);
done();
}, 1500);
});
});
\ No newline at end of file
#utf8 detector
Detect if a Buffer is utf8 encoded.
It need The minimum amount of bytes is 4.
```javascript
var fs = require('fs');
var isUtf8 = require('is-utf8');
var ansi = fs.readFileSync('ansi.txt');
var utf8 = fs.readFileSync('utf8.txt');
console.log('ansi.txt is utf8: '+isUtf8(ansi)); //false
console.log('utf8.txt is utf8: '+isUtf8(utf8)); //true
```
exports = module.exports = function(bytes)
{
var i = 0;
while(i < bytes.length)
{
if( (// ASCII
bytes[i] == 0x09 ||
bytes[i] == 0x0A ||
bytes[i] == 0x0D ||
(0x20 <= bytes[i] && bytes[i] <= 0x7E)
)
) {
i += 1;
continue;
}
if( (// non-overlong 2-byte
(0xC2 <= bytes[i] && bytes[i] <= 0xDF) &&
(0x80 <= bytes[i+1] && bytes[i+1] <= 0xBF)
)
) {
i += 2;
continue;
}
if( (// excluding overlongs
bytes[i] == 0xE0 &&
(0xA0 <= bytes[i + 1] && bytes[i + 1] <= 0xBF) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF)
) ||
(// straight 3-byte
((0xE1 <= bytes[i] && bytes[i] <= 0xEC) ||
bytes[i] == 0xEE ||
bytes[i] == 0xEF) &&
(0x80 <= bytes[i + 1] && bytes[i+1] <= 0xBF) &&
(0x80 <= bytes[i+2] && bytes[i+2] <= 0xBF)
) ||
(// excluding surrogates
bytes[i] == 0xED &&
(0x80 <= bytes[i+1] && bytes[i+1] <= 0x9F) &&
(0x80 <= bytes[i+2] && bytes[i+2] <= 0xBF)
)
) {
i += 3;
continue;
}
if( (// planes 1-3
bytes[i] == 0xF0 &&
(0x90 <= bytes[i + 1] && bytes[i + 1] <= 0xBF) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF) &&
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xBF)
) ||
(// planes 4-15
(0xF1 <= bytes[i] && bytes[i] <= 0xF3) &&
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0xBF) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF) &&
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xBF)
) ||
(// plane 16
bytes[i] == 0xF4 &&
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0x8F) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF) &&
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xBF)
)
) {
i += 4;
continue;
}
return false;
}
return true;
}
{
"_from": "is-utf8@^0.2.0",
"_id": "is-utf8@0.2.1",
"_inBundle": false,
"_integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=",
"_location": "/is-utf8",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "is-utf8@^0.2.0",
"name": "is-utf8",
"escapedName": "is-utf8",
"rawSpec": "^0.2.0",
"saveSpec": null,
"fetchSpec": "^0.2.0"
},
"_requiredBy": [
"/strip-bom"
],
"_resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
"_shasum": "4b0da1442104d1b336340e80797e865cf39f7d72",
"_spec": "is-utf8@^0.2.0",
"_where": "/tmp/tt/node_modules/strip-bom",
"author": {
"name": "wayfind"
},
"bugs": {
"url": "https://github.com/wayfind/is-utf8/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Detect if a buffer is utf8 encoded.",
"files": [
"is-utf8.js"
],
"homepage": "https://github.com/wayfind/is-utf8#readme",
"keywords": [
"utf8",
"charset"
],
"license": "MIT",
"main": "is-utf8.js",
"name": "is-utf8",
"repository": {
"type": "git",
"url": "git+https://github.com/wayfind/is-utf8.git"
},
"scripts": {
"test": "node test.js"
},
"version": "0.2.1"
}
#!/usr/bin/env node
'use strict';
var fs = require('fs');
var pkg = require('./package.json');
var stripBom = require('./');
var argv = process.argv.slice(2);
var input = argv[0];
function help() {
console.log([
'',
' ' + pkg.description,
'',
' Usage',
' strip-bom <file> > <new-file>',
' cat <file> | strip-bom > <new-file>',
'',
' Example',
' strip-bom unicorn.txt > unicorn-without-bom.txt'
].join('\n'));
}
if (argv.indexOf('--help') !== -1) {
help();
return;
}
if (argv.indexOf('--version') !== -1) {
console.log(pkg.version);
return;
}
if (process.stdin.isTTY) {
if (!input) {
help();
return;
}
fs.createReadStream(input).pipe(stripBom.stream()).pipe(process.stdout);
} else {
process.stdin.pipe(stripBom.stream()).pipe(process.stdout);
}
'use strict';
var isUtf8 = require('is-utf8');
var stripBom = module.exports = function (arg) {
if (typeof arg === 'string') {
return arg.replace(/^\ufeff/g, '');
}
if (Buffer.isBuffer(arg) && isUtf8(arg) &&
arg[0] === 0xef && arg[1] === 0xbb && arg[2] === 0xbf) {
return arg.slice(3);
}
return arg;
};
stripBom.stream = function () {
var firstChunk = require('first-chunk-stream');
return firstChunk({minSize: 3}, function (chunk, enc, cb) {
this.push(stripBom(chunk));
cb();
});
};
{
"_from": "strip-bom@^1.0.0",
"_id": "strip-bom@1.0.0",
"_inBundle": false,
"_integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=",
"_location": "/strip-bom",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "strip-bom@^1.0.0",
"name": "strip-bom",
"escapedName": "strip-bom",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/vinyl-fs"
],
"_resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz",
"_shasum": "85b8862f3844b5a6d5ec8467a93598173a36f794",
"_spec": "strip-bom@^1.0.0",
"_where": "/tmp/tt/node_modules/vinyl-fs",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"bin": {
"strip-bom": "cli.js"
},
"bugs": {
"url": "https://github.com/sindresorhus/strip-bom/issues"
},
"bundleDependencies": false,
"dependencies": {
"first-chunk-stream": "^1.0.0",
"is-utf8": "^0.2.0"
},
"deprecated": false,
"description": "Strip UTF-8 byte order mark (BOM) from a string/buffer/stream",
"devDependencies": {
"concat-stream": "^1.4.5",
"mocha": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"cli.js",
"index.js"
],
"homepage": "https://github.com/sindresorhus/strip-bom#readme",
"keywords": [
"cli",
"bin",
"app",
"bom",
"strip",
"byte",
"mark",
"unicode",
"utf8",
"utf-8",
"remove",
"trim",
"text",
"buffer",
"string",
"stream",
"streams"
],
"license": "MIT",
"name": "strip-bom",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/strip-bom.git"
},
"scripts": {
"test": "mocha"
},
"version": "1.0.0"
}
# strip-bom [![Build Status](https://travis-ci.org/sindresorhus/strip-bom.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-bom)
> Strip UTF-8 [byte order mark](http://en.wikipedia.org/wiki/Byte_order_mark#UTF-8) (BOM) from a string/buffer/stream
From Wikipedia:
> The Unicode Standard permits the BOM in UTF-8, but does not require nor recommend its use. Byte order has no meaning in UTF-8.
## Usage
```sh
$ npm install --save strip-bom
```
```js
var fs = require('fs');
var stripBom = require('strip-bom');
stripBom('\ufeffUnicorn');
//=> Unicorn
stripBom(fs.readFileSync('unicorn.txt'));
//=> Unicorn
```
Or as a [Transform stream](http://nodejs.org/api/stream.html#stream_class_stream_transform):
```js
var fs = require('fs');
var stripBom = require('strip-bom');
fs.createReadStream('unicorn.txt')
.pipe(stripBom.stream())
.pipe(fs.createWriteStream('unicorn.txt'));
```
## CLI
```sh
$ npm install --global strip-bom
```
```
$ strip-bom --help
Usage
strip-bom <file> > <new-file>
cat <file> | strip-bom > <new-file>
Example
strip-bom unicorn.txt > unicorn-without-bom.txt
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
# vinyl-fs [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Dependency Status](https://david-dm.org/wearefractal/vinyl.png?theme=shields.io)](https://david-dm.org/wearefractal/vinyl-fs)
## Information
<table>
<tr>
<td>Package</td><td>vinyl-fs</td>
</tr>
<tr>
<td>Description</td>
<td>Vinyl adapter for the file system</td>
</tr>
<tr>
<td>Node Version</td>
<td>>= 0.10</td>
</tr>
</table>
## Usage
```javascript
var map = require('map-stream');
var fs = require('vinyl-fs');
var log = function(file, cb) {
console.log(file.path);
cb(null, file);
};
fs.src(['./js/**/*.js', '!./js/vendor/*.js'])
.pipe(map(log))
.pipe(fs.dest('./output'));
```
## API
### src(globs[, opt])
- Takes a glob string or an array of glob strings as the first argument.
- Possible options for the second argument:
- cwd - Specify the working directory the folder is relative to. Default is `process.cwd()`
- base - Specify the folder relative to the cwd. Default is where the glob begins. This is used to determine the file names when saving in `.dest()`
- buffer - `true` or `false` if you want to buffer the file.
- Default value is `true`
- `false` will make file.contents a paused Stream
- read - `true` or `false` if you want the file to be read or not. Useful for stuff like `rm`ing files.
- Default value is `true`
- `false` will disable writing the file to disk via `.dest()`
- Any glob-related options are documented in [glob-stream] and [node-glob]
- Returns a Readable/Writable stream.
- On write the stream will simply pass items through.
- This stream emits matching [vinyl] File objects
### watch(globs[, opt, cb])
This is just [glob-watcher]
- Takes a glob string or an array of glob strings as the first argument.
- Possible options for the second argument:
- Any options are passed to [gaze]
- Returns an EventEmitter
- 'changed' event is emitted on each file change
- Optionally calls the callback on each change event
### dest(folder[, opt])
- Takes a folder path as the first argument.
- First argument can also be a function that takes in a file and returns a folder path.
- Possible options for the second argument:
- cwd - Specify the working directory the folder is relative to. Default is `process.cwd()`
- mode - Specify the mode the files should be created with. Default is the mode of the input file (file.stat.mode)
- Returns a Readable/Writable stream.
- On write the stream will save the [vinyl] File to disk at the folder/cwd specified.
- After writing the file to disk, it will be emitted from the stream so you can keep piping these around
- The file will be modified after being written to this stream
- `cwd`, `base`, and `path` will be overwritten to match the folder
- `stat.mode` will be overwritten if you used a mode parameter
- `contents` will have it's position reset to the beginning if it is a stream
[glob-stream]: https://github.com/wearefractal/glob-stream
[node-glob]: https://github.com/isaacs/node-glob
[gaze]: https://github.com/shama/gaze
[glob-watcher]: https://github.com/wearefractal/glob-watcher
[vinyl]: https://github.com/wearefractal/vinyl
[npm-url]: https://npmjs.org/package/vinyl-fs
[npm-image]: https://badge.fury.io/js/vinyl-fs.png
[travis-url]: https://travis-ci.org/wearefractal/vinyl-fs
[travis-image]: https://travis-ci.org/wearefractal/vinyl-fs.png?branch=master
[coveralls-url]: https://coveralls.io/r/wearefractal/vinyl-fs
[coveralls-image]: https://coveralls.io/repos/wearefractal/vinyl-fs/badge.png
[depstat-url]: https://david-dm.org/wearefractal/vinyl-fs
[depstat-image]: https://david-dm.org/wearefractal/vinyl-fs.png
'use strict';
module.exports = {
src: require('./lib/src'),
dest: require('./lib/dest'),
watch: require('glob-watcher')
};
'use strict';
var defaults = require('defaults');
var path = require('path');
var through2 = require('through2');
var mkdirp = require('mkdirp');
var fs = require('graceful-fs');
var writeContents = require('./writeContents');
function dest(outFolder, opt) {
opt = opt || {};
if (typeof outFolder !== 'string' && typeof outFolder !== 'function') {
throw new Error('Invalid output folder');
}
var options = defaults(opt, {
cwd: process.cwd()
});
if (typeof options.mode === 'string') {
options.mode = parseInt(options.mode, 8);
}
var cwd = path.resolve(options.cwd);
function saveFile (file, enc, cb) {
var basePath;
if (typeof outFolder === 'string') {
basePath = path.resolve(cwd, outFolder);
}
if (typeof outFolder === 'function') {
basePath = path.resolve(cwd, outFolder(file));
}
var writePath = path.resolve(basePath, file.relative);
var writeFolder = path.dirname(writePath);
// wire up new properties
file.stat = file.stat ? file.stat : new fs.Stats();
file.stat.mode = (options.mode || file.stat.mode);
file.cwd = cwd;
file.base = basePath;
file.path = writePath;
// mkdirp the folder the file is going in
mkdirp(writeFolder, function(err){
if (err) {
return cb(err);
}
writeContents(writePath, file, cb);
});
}
var stream = through2.obj(saveFile);
// TODO: option for either backpressure or lossy
stream.resume();
return stream;
}
module.exports = dest;
'use strict';
var fs = require('fs');
var writeDir = require('./writeDir');
var writeStream = require('./writeStream');
var writeBuffer = require('./writeBuffer');
function writeContents(writePath, file, cb) {
var written = function(err) {
var done = function(err) {
cb(err, file);
};
if (err) {
return done(err);
}
if (!file.stat || typeof file.stat.mode !== 'number') {
return done();
}
fs.stat(writePath, function(err, st) {
if (err) {
return done(err);
}
// octal 7777 = decimal 4095
var currentMode = (st.mode & 4095);
if (currentMode === file.stat.mode) {
return done();
}
fs.chmod(writePath, file.stat.mode, done);
});
};
// if directory then mkdirp it
if (file.isDirectory()) {
writeDir(writePath, file, written);
return;
}
// stream it to disk yo
if (file.isStream()) {
writeStream(writePath, file, written);
return;
}
// write it like normal
if (file.isBuffer()) {
writeBuffer(writePath, file, written);
return;
}
// if no contents then do nothing
if (file.isNull()) {
cb(null, file);
return;
}
}
module.exports = writeContents;
'use strict';
var fs = require('graceful-fs');
function writeBuffer(writePath, file, cb) {
var opt = {
mode: file.stat.mode
};
fs.writeFile(writePath, file.contents, opt, cb);