This commit is contained in:
2019-02-17 18:07:28 +01:00
parent c69ffb9752
commit 95cff6f702
2301 changed files with 307810 additions and 5 deletions

13
Client/node_modules/gulp-vinyl-zip/.eslintrc generated vendored Executable file
View File

@@ -0,0 +1,13 @@
{
"env": {
"node": true
},
"rules": {
"no-console": 0,
"no-cond-assign": 0,
"no-unused-vars": 1,
"no-extra-semi": "warn",
"semi": "warn"
},
"extends": "eslint:recommended"
}

6
Client/node_modules/gulp-vinyl-zip/.travis.yml generated vendored Executable file
View File

@@ -0,0 +1,6 @@
language: node_js
node_js:
- "4"
- "5"
- "6"
sudo: false

78
Client/node_modules/gulp-vinyl-zip/README.md generated vendored Executable file
View File

@@ -0,0 +1,78 @@
# gulp-vinyl-zip
[![Build Status](https://travis-ci.org/joaomoreno/gulp-vinyl-zip.svg?branch=master)](https://travis-ci.org/joaomoreno/gulp-vinyl-zip)
A library for creating and extracting ZIP archives from/to streams.
Uses [yazl](https://github.com/thejoshwolfe/yazl)
and [yauzl](https://github.com/thejoshwolfe/yauzl).
## Usage
**Archive → Archive**
```javascript
var gulp = require('gulp');
var zip = require('gulp-vinyl-zip');
gulp.task('default', function () {
return zip.src('src.zip')
.pipe(/* knock yourself out */)
.pipe(zip.dest('out.zip'));
});
```
or
```javascript
var gulp = require('gulp');
var zip = require('gulp-vinyl-zip');
gulp.task('default', function () {
return gulp.src('src.zip')
.pipe(zip.src())
.pipe(/* knock yourself out */)
.pipe(zip.dest('out.zip'));
});
```
**Archive → File System**
```javascript
var gulp = require('gulp');
var zip = require('gulp-vinyl-zip');
gulp.task('default', function () {
return zip.src('src.zip')
.pipe(/* knock yourself out */)
.pipe(gulp.dest('out'));
});
```
**File System → Archive**
```javascript
var gulp = require('gulp');
var zip = require('gulp-vinyl-zip');
gulp.task('default', function () {
return gulp.src('src/**/*')
.pipe(/* knock yourself out */)
.pipe(zip.dest('out.zip'));
});
```
**File System → Archive Stream → Disk**
```javascript
var gulp = require('gulp');
var zip = require('gulp-vinyl-zip').zip; // zip transform only
gulp.task('default', function () {
return gulp.src('src/**/*')
.pipe(/* knock yourself out */)
.pipe(zip('out.zip'))
.pipe(/* knock your zip out */)
.pipe(gulp.dest('./'));
});
```

7
Client/node_modules/gulp-vinyl-zip/index.js generated vendored Executable file
View File

@@ -0,0 +1,7 @@
'use strict';
module.exports = {
src: require('./lib/src'),
zip: require('./lib/zip'),
dest: require('./lib/dest')
};

32
Client/node_modules/gulp-vinyl-zip/lib/dest/index.js generated vendored Executable file
View File

@@ -0,0 +1,32 @@
'use strict';
var through = require('through2');
var vfs = require('vinyl-fs');
var zip = require('../zip');
var path = require('path');
function dest(zipPath, opts) {
var input = zip(path.basename(zipPath), opts);
var output = vfs.dest(path.dirname(zipPath), opts);
var stream = through.obj(function(file, enc, cb) {
input.write(file);
cb();
}, function(cb) {
input.end();
output.on('end', function() {
stream.end();
cb();
});
});
input.pipe(output);
output.on('data', function(data) {
stream.push(data);
});
stream.resume();
return stream;
}
module.exports = dest;

156
Client/node_modules/gulp-vinyl-zip/lib/src/index.js generated vendored Executable file
View File

@@ -0,0 +1,156 @@
'use strict';
var fs = require('fs');
var yauzl = require('yauzl');
var es = require('event-stream');
var File = require('../vinyl-zip');
var queue = require('queue');
var constants = require('constants');
function modeFromEntry(entry) {
var attr = entry.externalFileAttributes >> 16 || 33188;
return [448 /* S_IRWXU */, 56 /* S_IRWXG */, 7 /* S_IRWXO */]
.map(function(mask) { return attr & mask; })
.reduce(function(a, b) { return a + b; }, attr & 61440 /* S_IFMT */);
}
function mtimeFromEntry(entry) {
return yauzl.dosDateTimeToDate(entry.lastModFileDate, entry.lastModFileTime);
}
function toStream(zip) {
var result = es.through();
var q = queue();
var didErr = false;
q.on('error', function (err) {
didErr = true;
result.emit('error', err);
});
zip.on('entry', function (entry) {
if (didErr) { return; }
var stat = new fs.Stats();
stat.mode = modeFromEntry(entry);
stat.mtime = mtimeFromEntry(entry);
// directories
if (/\/$/.test(entry.fileName)) {
stat.mode = (stat.mode & ~constants.S_IFMT) | constants.S_IFDIR;
}
var file = {
path: entry.fileName,
stat: stat
};
if (stat.isFile()) {
if (entry.uncompressedSize === 0) {
file.contents = new Buffer(0);
result.emit('data', new File(file));
} else {
q.push(function (cb) {
zip.openReadStream(entry, function(err, readStream) {
if (err) { return cb(err); }
file.contents = readStream;
result.emit('data', new File(file));
cb();
});
});
q.start();
}
} else if (stat.isSymbolicLink()) {
q.push(function (cb) {
zip.openReadStream(entry, function(err, readStream) {
if (err) { return cb(err); }
file.symlink = '';
readStream.on('data', function(c) { file.symlink += c; });
readStream.on('error', cb);
readStream.on('end', function () {
result.emit('data', new File(file));
cb();
});
});
});
q.start();
} else if (stat.isDirectory()) {
file.contents = null;
result.emit('data', new File(file));
} else {
result.emit('data', new File(file));
}
});
zip.on('end', function() {
if (didErr) {
return;
}
if (q.length === 0) {
result.end();
} else {
q.on('end', function () {
result.end();
});
}
});
return result;
}
function unzipBuffer(contents) {
var result = es.through();
yauzl.fromBuffer(contents, function (err, zip) {
if (err) { return result.emit('error', err); }
toStream(zip).pipe(result);
});
return result;
}
function unzipFile(zipPath) {
var result = es.through();
yauzl.open(zipPath, function (err, zip) {
if (err) { return result.emit('error', err); }
toStream(zip).pipe(result);
});
return result;
}
function unzip() {
var input = es.through();
var result = es.through();
var zips = [];
var output = input.pipe(es.through(function (f) {
if (!f.isBuffer()) {
this.emit('error', new Error('Only supports buffers'));
}
zips.push(f);
}, function () {
var streams = zips.map(function (f) {
return unzipBuffer(f.contents);
});
es.merge(streams).pipe(result);
this.emit('end');
}));
return es.duplex(input, es.merge(output, result));
}
function src(zipPath) {
return zipPath ? unzipFile(zipPath) : unzip();
}
module.exports = src;

11
Client/node_modules/gulp-vinyl-zip/lib/vinyl-zip.js generated vendored Executable file
View File

@@ -0,0 +1,11 @@
'use strict';
var File = require('vinyl');
class ZipFile extends File {
constructor(file) {
super(file);
}
}
module.exports = ZipFile;

60
Client/node_modules/gulp-vinyl-zip/lib/zip/index.js generated vendored Executable file
View File

@@ -0,0 +1,60 @@
'use strict';
var through = require('through2');
var yazl = require('yazl');
var File = require('../vinyl-zip');
function zip(zipPath, options) {
if (!zipPath) throw new Error('No zip path specified.');
options = options || {};
var zip = new yazl.ZipFile();
var isEmpty = true;
var stream = through.obj(function(file, enc, cb) {
var stat = file.stat || {};
var opts = {
mtime: stat.mtime,
mode: stat.mode
};
opts.compress = options.compress;
var path = file.relative.replace(/\\/g, '/');
if (stat.isSymbolicLink && stat.isSymbolicLink()) {
zip.addBuffer(new Buffer(file.symlink), path, opts);
} else if (file.isDirectory()) {
// In Windows, directories have a 666 permissions. This doesn't go well
// on OS X and Linux, where directories are expected to be 755.
if (/win32/.test(process.platform)) {
opts.mode = 16877;
}
zip.addEmptyDirectory(path, opts);
} else if (file.isBuffer()) {
zip.addBuffer(file.contents, path, opts);
} else if (file.isStream()) {
zip.addReadStream(file.contents, path, opts);
}
isEmpty = false;
cb();
}, function(cb) {
if (isEmpty && options.unlessEmpty) {
return cb();
}
stream.push(new File({path: zipPath, contents: zip.outputStream}));
zip.end(function() {
cb();
});
});
stream.resume();
return stream;
}
module.exports = zip;

View File

@@ -0,0 +1,21 @@
## The MIT License (MIT) ##
Copyright (c) 2014 Hugh Kennedy
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.

View File

@@ -0,0 +1,17 @@
# clone-stats [![Flattr this!](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=hughskennedy&url=http://github.com/hughsk/clone-stats&title=clone-stats&description=hughsk/clone-stats%20on%20GitHub&language=en_GB&tags=flattr,github,javascript&category=software)[![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) #
Safely clone node's
[`fs.Stats`](http://nodejs.org/api/fs.html#fs_class_fs_stats) instances without
losing their class methods, i.e. `stat.isDirectory()` and co.
## Usage ##
[![clone-stats](https://nodei.co/npm/clone-stats.png?mini=true)](https://nodei.co/npm/clone-stats)
### `copy = require('clone-stats')(stat)` ###
Returns a clone of the original `fs.Stats` instance (`stat`).
## License ##
MIT. See [LICENSE.md](http://github.com/hughsk/clone-stats/blob/master/LICENSE.md) for details.

View File

@@ -0,0 +1,13 @@
var Stat = require('fs').Stats
module.exports = cloneStats
function cloneStats(stats) {
var replacement = new Stat
Object.keys(stats).forEach(function(key) {
replacement[key] = stats[key]
})
return replacement
}

View File

@@ -0,0 +1,60 @@
{
"_from": "clone-stats@^1.0.0",
"_id": "clone-stats@1.0.0",
"_inBundle": false,
"_integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=",
"_location": "/gulp-vinyl-zip/clone-stats",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "clone-stats@^1.0.0",
"name": "clone-stats",
"escapedName": "clone-stats",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/gulp-vinyl-zip/vinyl"
],
"_resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz",
"_shasum": "b3782dff8bb5474e18b9b6bf0fdfe782f8777680",
"_spec": "clone-stats@^1.0.0",
"_where": "/home/nathan/Projects/Upsilon/UpsilonVsCodeLanguageServer/Client/node_modules/gulp-vinyl-zip/node_modules/vinyl",
"author": {
"name": "Hugh Kennedy",
"email": "hughskennedy@gmail.com",
"url": "http://hughsk.io/"
},
"browser": "index.js",
"bugs": {
"url": "https://github.com/hughsk/clone-stats/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "Safely clone node's fs.Stats instances without losing their class methods",
"devDependencies": {
"tape": "~2.3.2"
},
"homepage": "https://github.com/hughsk/clone-stats",
"keywords": [
"stats",
"fs",
"clone",
"copy",
"prototype"
],
"license": "MIT",
"main": "index.js",
"name": "clone-stats",
"repository": {
"type": "git",
"url": "git://github.com/hughsk/clone-stats.git"
},
"scripts": {
"test": "node test"
},
"version": "1.0.0"
}

View File

@@ -0,0 +1,36 @@
var test = require('tape')
var clone = require('./')
var fs = require('fs')
test('file', function(t) {
compare(t, fs.statSync(__filename))
t.end()
})
test('directory', function(t) {
compare(t, fs.statSync(__dirname))
t.end()
})
function compare(t, stat) {
var copy = clone(stat)
t.deepEqual(stat, copy, 'clone has equal properties')
t.ok(stat instanceof fs.Stats, 'original is an fs.Stat')
t.ok(copy instanceof fs.Stats, 'copy is an fs.Stat')
;['isDirectory'
, 'isFile'
, 'isBlockDevice'
, 'isCharacterDevice'
, 'isSymbolicLink'
, 'isFIFO'
, 'isSocket'
].forEach(function(method) {
t.equal(
stat[method].call(stat)
, copy[method].call(copy)
, 'equal value for stat.' + method + '()'
)
})
}

View File

@@ -0,0 +1,4 @@
/node_modules/
/test.js
/.travis.yml
*.html

View File

@@ -0,0 +1,18 @@
Copyright © 2011-2015 Paul Vorbach <paul@vorba.ch>
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, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,194 @@
# clone
[![build status](https://secure.travis-ci.org/pvorb/clone.svg)](http://travis-ci.org/pvorb/clone) [![downloads](https://img.shields.io/npm/dt/clone.svg)](http://npm-stat.com/charts.html?package=clone)
offers foolproof _deep cloning_ of objects, arrays, numbers, strings, maps,
sets, promises, etc. in JavaScript.
**XSS vulnerability detected**
## Installation
npm install clone
(It also works with browserify, ender or standalone. You may want to use the
option `noParse` in browserify to reduce the resulting file size, since usually
`Buffer`s are not needed in browsers.)
## Example
~~~ javascript
var clone = require('clone');
var a, b;
a = { foo: { bar: 'baz' } }; // initial value of a
b = clone(a); // clone a -> b
a.foo.bar = 'foo'; // change a
console.log(a); // show a
console.log(b); // show b
~~~
This will print:
~~~ javascript
{ foo: { bar: 'foo' } }
{ foo: { bar: 'baz' } }
~~~
**clone** masters cloning simple objects (even with custom prototype), arrays,
Date objects, and RegExp objects. Everything is cloned recursively, so that you
can clone dates in arrays in objects, for example.
## API
`clone(val, circular, depth)`
* `val` -- the value that you want to clone, any type allowed
* `circular` -- boolean
Call `clone` with `circular` set to `false` if you are certain that `obj`
contains no circular references. This will give better performance if
needed. There is no error if `undefined` or `null` is passed as `obj`.
* `depth` -- depth to which the object is to be cloned (optional,
defaults to infinity)
* `prototype` -- sets the prototype to be used when cloning an object.
(optional, defaults to parent prototype).
* `includeNonEnumerable` -- set to `true` if the non-enumerable properties
should be cloned as well. Non-enumerable properties on the prototype chain
will be ignored. (optional, defaults to `false`)
`clone.clonePrototype(obj)`
* `obj` -- the object that you want to clone
Does a prototype clone as
[described by Oran Looney](http://oranlooney.com/functional-javascript/).
## Circular References
~~~ javascript
var a, b;
a = { hello: 'world' };
a.myself = a;
b = clone(a);
console.log(b);
~~~
This will print:
~~~ javascript
{ hello: "world", myself: [Circular] }
~~~
So, `b.myself` points to `b`, not `a`. Neat!
## Test
npm test
## Changelog
### v2.1.2
#### 2018-03-21
- Use `Buffer.allocUnsafe()` on Node >= 4.5.0 (contributed by @ChALkeR)
### v2.1.1
#### 2017-03-09
- Fix build badge in README
- Add support for cloning Maps and Sets on Internet Explorer
### v2.1.0
#### 2016-11-22
- Add support for cloning Errors
- Exclude non-enumerable symbol-named object properties from cloning
- Add option to include non-enumerable own properties of objects
### v2.0.0
#### 2016-09-28
- Add support for cloning ES6 Maps, Sets, Promises, and Symbols
### v1.0.3
#### 2017-11-08
- Close XSS vulnerability in the NPM package, which included the file
`test-apart-ctx.html`. This vulnerability was disclosed by Juho Nurminen of
2NS - Second Nature Security.
### v1.0.2 (deprecated)
#### 2015-03-25
- Fix call on getRegExpFlags
- Refactor utilities
- Refactor test suite
### v1.0.1 (deprecated)
#### 2015-03-04
- Fix nodeunit version
- Directly call getRegExpFlags
### v1.0.0 (deprecated)
#### 2015-02-10
- Improve browser support
- Improve browser testability
- Move helper methods to private namespace
## Caveat
Some special objects like a socket or `process.stdout`/`stderr` are known to not
be cloneable. If you find other objects that cannot be cloned, please [open an
issue](https://github.com/pvorb/clone/issues/new).
## Bugs and Issues
If you encounter any bugs or issues, feel free to [open an issue at
github](https://github.com/pvorb/clone/issues) or send me an email to
<paul@vorba.ch>. I also always like to hear from you, if youre using my code.
## License
Copyright © 2011-2016 [Paul Vorbach](https://paul.vorba.ch/) and
[contributors](https://github.com/pvorb/clone/graphs/contributors).
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, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="clone node_modules" level="project" />
</component>
</module>

View File

@@ -0,0 +1,257 @@
var clone = (function() {
'use strict';
function _instanceof(obj, type) {
return type != null && obj instanceof type;
}
var nativeMap;
try {
nativeMap = Map;
} catch(_) {
// maybe a reference error because no `Map`. Give it a dummy value that no
// value will ever be an instanceof.
nativeMap = function() {};
}
var nativeSet;
try {
nativeSet = Set;
} catch(_) {
nativeSet = function() {};
}
var nativePromise;
try {
nativePromise = Promise;
} catch(_) {
nativePromise = function() {};
}
/**
* Clones (copies) an Object using deep copying.
*
* This function supports circular references by default, but if you are certain
* there are no circular references in your object, you can save some CPU time
* by calling clone(obj, false).
*
* Caution: if `circular` is false and `parent` contains circular references,
* your program may enter an infinite loop and crash.
*
* @param `parent` - the object to be cloned
* @param `circular` - set to true if the object to be cloned may contain
* circular references. (optional - true by default)
* @param `depth` - set to a number if the object is only to be cloned to
* a particular depth. (optional - defaults to Infinity)
* @param `prototype` - sets the prototype to be used when cloning an object.
* (optional - defaults to parent prototype).
* @param `includeNonEnumerable` - set to true if the non-enumerable properties
* should be cloned as well. Non-enumerable properties on the prototype
* chain will be ignored. (optional - false by default)
*/
function clone(parent, circular, depth, prototype, includeNonEnumerable) {
if (typeof circular === 'object') {
depth = circular.depth;
prototype = circular.prototype;
includeNonEnumerable = circular.includeNonEnumerable;
circular = circular.circular;
}
// maintain two arrays for circular references, where corresponding parents
// and children have the same index
var allParents = [];
var allChildren = [];
var useBuffer = typeof Buffer != 'undefined';
if (typeof circular == 'undefined')
circular = true;
if (typeof depth == 'undefined')
depth = Infinity;
// recurse this function so we don't reset allParents and allChildren
function _clone(parent, depth) {
// cloning null always returns null
if (parent === null)
return null;
if (depth === 0)
return parent;
var child;
var proto;
if (typeof parent != 'object') {
return parent;
}
if (_instanceof(parent, nativeMap)) {
child = new nativeMap();
} else if (_instanceof(parent, nativeSet)) {
child = new nativeSet();
} else if (_instanceof(parent, nativePromise)) {
child = new nativePromise(function (resolve, reject) {
parent.then(function(value) {
resolve(_clone(value, depth - 1));
}, function(err) {
reject(_clone(err, depth - 1));
});
});
} else if (clone.__isArray(parent)) {
child = [];
} else if (clone.__isRegExp(parent)) {
child = new RegExp(parent.source, __getRegExpFlags(parent));
if (parent.lastIndex) child.lastIndex = parent.lastIndex;
} else if (clone.__isDate(parent)) {
child = new Date(parent.getTime());
} else if (useBuffer && Buffer.isBuffer(parent)) {
if (Buffer.allocUnsafe) {
// Node.js >= 4.5.0
child = Buffer.allocUnsafe(parent.length);
} else {
// Older Node.js versions
child = new Buffer(parent.length);
}
parent.copy(child);
return child;
} else if (_instanceof(parent, Error)) {
child = Object.create(parent);
} else {
if (typeof prototype == 'undefined') {
proto = Object.getPrototypeOf(parent);
child = Object.create(proto);
}
else {
child = Object.create(prototype);
proto = prototype;
}
}
if (circular) {
var index = allParents.indexOf(parent);
if (index != -1) {
return allChildren[index];
}
allParents.push(parent);
allChildren.push(child);
}
if (_instanceof(parent, nativeMap)) {
parent.forEach(function(value, key) {
var keyChild = _clone(key, depth - 1);
var valueChild = _clone(value, depth - 1);
child.set(keyChild, valueChild);
});
}
if (_instanceof(parent, nativeSet)) {
parent.forEach(function(value) {
var entryChild = _clone(value, depth - 1);
child.add(entryChild);
});
}
for (var i in parent) {
var attrs;
if (proto) {
attrs = Object.getOwnPropertyDescriptor(proto, i);
}
if (attrs && attrs.set == null) {
continue;
}
child[i] = _clone(parent[i], depth - 1);
}
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(parent);
for (var i = 0; i < symbols.length; i++) {
// Don't need to worry about cloning a symbol because it is a primitive,
// like a number or string.
var symbol = symbols[i];
var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
continue;
}
child[symbol] = _clone(parent[symbol], depth - 1);
if (!descriptor.enumerable) {
Object.defineProperty(child, symbol, {
enumerable: false
});
}
}
}
if (includeNonEnumerable) {
var allPropertyNames = Object.getOwnPropertyNames(parent);
for (var i = 0; i < allPropertyNames.length; i++) {
var propertyName = allPropertyNames[i];
var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
if (descriptor && descriptor.enumerable) {
continue;
}
child[propertyName] = _clone(parent[propertyName], depth - 1);
Object.defineProperty(child, propertyName, {
enumerable: false
});
}
}
return child;
}
return _clone(parent, depth);
}
/**
* Simple flat clone using prototype, accepts only objects, usefull for property
* override on FLAT configuration object (no nested props).
*
* USE WITH CAUTION! This may not behave as you wish if you do not know how this
* works.
*/
clone.clonePrototype = function clonePrototype(parent) {
if (parent === null)
return null;
var c = function () {};
c.prototype = parent;
return new c();
};
// private utility functions
function __objToStr(o) {
return Object.prototype.toString.call(o);
}
clone.__objToStr = __objToStr;
function __isDate(o) {
return typeof o === 'object' && __objToStr(o) === '[object Date]';
}
clone.__isDate = __isDate;
function __isArray(o) {
return typeof o === 'object' && __objToStr(o) === '[object Array]';
}
clone.__isArray = __isArray;
function __isRegExp(o) {
return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
}
clone.__isRegExp = __isRegExp;
function __getRegExpFlags(re) {
var flags = '';
if (re.global) flags += 'g';
if (re.ignoreCase) flags += 'i';
if (re.multiline) flags += 'm';
return flags;
}
clone.__getRegExpFlags = __getRegExpFlags;
return clone;
})();
if (typeof module === 'object' && module.exports) {
module.exports = clone;
}

View File

@@ -0,0 +1,158 @@
{
"_from": "clone@^2.1.1",
"_id": "clone@2.1.2",
"_inBundle": false,
"_integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=",
"_location": "/gulp-vinyl-zip/clone",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "clone@^2.1.1",
"name": "clone",
"escapedName": "clone",
"rawSpec": "^2.1.1",
"saveSpec": null,
"fetchSpec": "^2.1.1"
},
"_requiredBy": [
"/gulp-vinyl-zip/vinyl"
],
"_resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
"_shasum": "1b7f4b9f591f1e8f83670401600345a02887435f",
"_spec": "clone@^2.1.1",
"_where": "/home/nathan/Projects/Upsilon/UpsilonVsCodeLanguageServer/Client/node_modules/gulp-vinyl-zip/node_modules/vinyl",
"author": {
"name": "Paul Vorbach",
"email": "paul@vorba.ch",
"url": "http://paul.vorba.ch/"
},
"bugs": {
"url": "https://github.com/pvorb/node-clone/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Blake Miner",
"email": "miner.blake@gmail.com",
"url": "http://www.blakeminer.com/"
},
{
"name": "Tian You",
"email": "axqd001@gmail.com",
"url": "http://blog.axqd.net/"
},
{
"name": "George Stagas",
"email": "gstagas@gmail.com",
"url": "http://stagas.com/"
},
{
"name": "Tobiasz Cudnik",
"email": "tobiasz.cudnik@gmail.com",
"url": "https://github.com/TobiaszCudnik"
},
{
"name": "Pavel Lang",
"email": "langpavel@phpskelet.org",
"url": "https://github.com/langpavel"
},
{
"name": "Dan MacTough",
"url": "http://yabfog.com/"
},
{
"name": "w1nk",
"url": "https://github.com/w1nk"
},
{
"name": "Hugh Kennedy",
"url": "http://twitter.com/hughskennedy"
},
{
"name": "Dustin Diaz",
"url": "http://dustindiaz.com"
},
{
"name": "Ilya Shaisultanov",
"url": "https://github.com/diversario"
},
{
"name": "Nathan MacInnes",
"email": "nathan@macinn.es",
"url": "http://macinn.es/"
},
{
"name": "Benjamin E. Coe",
"email": "ben@npmjs.com",
"url": "https://twitter.com/benjamincoe"
},
{
"name": "Nathan Zadoks",
"url": "https://github.com/nathan7"
},
{
"name": "Róbert Oroszi",
"email": "robert+gh@oroszi.net",
"url": "https://github.com/oroce"
},
{
"name": "Aurélio A. Heckert",
"url": "http://softwarelivre.org/aurium"
},
{
"name": "Guy Ellis",
"url": "http://www.guyellisrocks.com/"
},
{
"name": "fscherwi",
"url": "https://fscherwi.github.io"
},
{
"name": "rictic",
"url": "https://github.com/rictic"
},
{
"name": "Martin Jurča",
"url": "https://github.com/jurca"
},
{
"name": "Misery Lee",
"email": "miserylee@foxmail.com",
"url": "https://github.com/miserylee"
},
{
"name": "Clemens Wolff",
"url": "https://github.com/c-w"
}
],
"dependencies": {},
"deprecated": false,
"description": "deep cloning of objects and arrays",
"devDependencies": {
"nodeunit": "~0.9.0"
},
"engines": {
"node": ">=0.8"
},
"homepage": "https://github.com/pvorb/node-clone#readme",
"license": "MIT",
"main": "clone.js",
"name": "clone",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git://github.com/pvorb/node-clone.git"
},
"scripts": {
"test": "nodeunit test.js"
},
"tags": [
"clone",
"object",
"array",
"function",
"date"
],
"version": "2.1.2"
}

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015-2017 Blaine Bublitz <blaine.bublitz@gmail.com>, Eric Schoffstall <yo@contra.io> and other contributors
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.

View File

@@ -0,0 +1,146 @@
<p align="center">
<a href="http://gulpjs.com">
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
</a>
</p>
# glob-stream
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
A [Readable Stream][readable-stream-url] interface over [node-glob][node-glob-url].
## Usage
```javascript
var gs = require('glob-stream');
var readable = gs('./files/**/*.coffee', { /* options */ });
var writable = /* your WriteableStream */
readable.pipe(writable);
```
You can pass any combination of glob strings. One caveat is that you cannot __only__ pass a negative glob, you must give it at least one positive glob so it knows where to start. If given a non-glob path (also referred to as a singular glob), only one file will be emitted. If given a singular glob and no files match, an error is emitted (see also [`options.allowEmpty`][allow-empty-url]).
## API
### `globStream(globs, options)`
Takes a glob string or an array of glob strings as the first argument and an options object as the second. Returns a stream of objects that contain `cwd`, `base` and `path` properties.
#### Options
##### `options.allowEmpty`
Whether or not to error upon an empty singular glob.
Type: `Boolean`
Default: `false` (error upon no match)
##### `options.dot`
Whether or not to treat dotfiles as regular files. This is passed through to [node-glob][node-glob-url].
Type: `Boolean`
Default: `false`
##### `options.silent`
Whether or not to suppress warnings on stderr from [node-glob][node-glob-url]. This is passed through to [node-glob][node-glob-url].
Type: `Boolean`
Default: `true`
##### `options.cwd`
The current working directory that the glob is resolved against.
Type: `String`
Default: `process.cwd()`
##### `options.root`
The root path that the glob is resolved against.
__Note: This is never passed to [node-glob][node-glob-url] because it is pre-resolved against your paths.__
Type: `String`
Default: `undefined` (use the filesystem root)
##### `options.base`
The absolute segment of the glob path that isn't a glob. This value is attached to each glob object and is useful for relative pathing.
Type: `String`
Default: The absolute path segement before a glob starts (see [glob-parent][glob-parent-url])
##### `options.cwdbase`
Whether or not the `cwd` and `base` should be the same.
Type: `Boolean`
Default: `false`
##### `options.uniqueBy`
Filters stream to remove duplicates based on the string property name or the result of function. When using a function, the function receives the streamed data (objects containing `cwd`, `base`, `path` properties) to compare against.
Type: `String` or `Function`
Default: `'path'`
##### other
Any glob-related options are documented in [node-glob][node-glob-url]. Those options are forwarded verbatim, with the exception of `root` and `ignore`. `root` is pre-resolved and `ignore` is joined with all negative globs.
#### Globbing & Negation
```js
var stream = gs(['./**/*.js', '!./node_modules/**/*']);
```
Globs are executed in order, so negations should follow positive globs. For example:
The following would __not__ exclude any files:
```js
gs(['!b*.js', '*.js'])
```
However, this would exclude all files that started with `b`:
```js
gs(['*.js', '!b*.js'])
```
## License
MIT
[node-glob-url]: https://github.com/isaacs/node-glob
[glob-parent-url]: https://github.com/es128/glob-parent
[allow-empty-url]: #optionsallowempty
[readable-stream-url]: https://nodejs.org/api/stream.html#stream_readable_streams
[downloads-image]: http://img.shields.io/npm/dm/glob-stream.svg
[npm-url]: https://www.npmjs.com/package/glob-stream
[npm-image]: http://img.shields.io/npm/v/glob-stream.svg
[travis-url]: https://travis-ci.org/gulpjs/glob-stream
[travis-image]: http://img.shields.io/travis/gulpjs/glob-stream.svg?label=travis-ci
[appveyor-url]: https://ci.appveyor.com/project/gulpjs/glob-stream
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/glob-stream.svg?label=appveyor
[coveralls-url]: https://coveralls.io/r/gulpjs/glob-stream
[coveralls-image]: http://img.shields.io/coveralls/gulpjs/glob-stream.svg
[gitter-url]: https://gitter.im/gulpjs/gulp
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg

View File

@@ -0,0 +1,94 @@
'use strict';
var Combine = require('ordered-read-streams');
var unique = require('unique-stream');
var pumpify = require('pumpify');
var isNegatedGlob = require('is-negated-glob');
var extend = require('extend');
var GlobStream = require('./readable');
function globStream(globs, opt) {
if (!opt) {
opt = {};
}
var ourOpt = extend({}, opt);
var ignore = ourOpt.ignore;
ourOpt.cwd = typeof ourOpt.cwd === 'string' ? ourOpt.cwd : process.cwd();
ourOpt.dot = typeof ourOpt.dot === 'boolean' ? ourOpt.dot : false;
ourOpt.silent = typeof ourOpt.silent === 'boolean' ? ourOpt.silent : true;
ourOpt.cwdbase = typeof ourOpt.cwdbase === 'boolean' ? ourOpt.cwdbase : false;
ourOpt.uniqueBy = typeof ourOpt.uniqueBy === 'string' ||
typeof ourOpt.uniqueBy === 'function' ? ourOpt.uniqueBy : 'path';
if (ourOpt.cwdbase) {
ourOpt.base = ourOpt.cwd;
}
// Normalize string `ignore` to array
if (typeof ignore === 'string') {
ignore = [ignore];
}
// Ensure `ignore` is an array
if (!Array.isArray(ignore)) {
ignore = [];
}
// Only one glob no need to aggregate
if (!Array.isArray(globs)) {
globs = [globs];
}
var positives = [];
var negatives = [];
globs.forEach(sortGlobs);
function sortGlobs(globString, index) {
if (typeof globString !== 'string') {
throw new Error('Invalid glob at index ' + index);
}
var glob = isNegatedGlob(globString);
var globArray = glob.negated ? negatives : positives;
globArray.push({
index: index,
glob: glob.pattern,
});
}
if (positives.length === 0) {
throw new Error('Missing positive glob');
}
// Create all individual streams
var streams = positives.map(streamFromPositive);
// Then just pipe them to a single unique stream and return it
var aggregate = new Combine(streams);
var uniqueStream = unique(ourOpt.uniqueBy);
return pumpify.obj(aggregate, uniqueStream);
function streamFromPositive(positive) {
var negativeGlobs = negatives
.filter(indexGreaterThan(positive.index))
.map(toGlob)
.concat(ignore);
return new GlobStream(positive.glob, negativeGlobs, ourOpt);
}
}
function indexGreaterThan(index) {
return function(obj) {
return obj.index > index;
};
}
function toGlob(obj) {
return obj.glob;
}
module.exports = globStream;

View File

@@ -0,0 +1,101 @@
{
"_from": "glob-stream@^6.1.0",
"_id": "glob-stream@6.1.0",
"_inBundle": false,
"_integrity": "sha1-cEXJlBOz65SIjYOrRtC0BMx73eQ=",
"_location": "/gulp-vinyl-zip/glob-stream",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "glob-stream@^6.1.0",
"name": "glob-stream",
"escapedName": "glob-stream",
"rawSpec": "^6.1.0",
"saveSpec": null,
"fetchSpec": "^6.1.0"
},
"_requiredBy": [
"/gulp-vinyl-zip/vinyl-fs"
],
"_resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-6.1.0.tgz",
"_shasum": "7045c99413b3eb94888d83ab46d0b404cc7bdde4",
"_spec": "glob-stream@^6.1.0",
"_where": "/home/nathan/Projects/Upsilon/UpsilonVsCodeLanguageServer/Client/node_modules/gulp-vinyl-zip/node_modules/vinyl-fs",
"author": {
"name": "Gulp Team",
"email": "team@gulpjs.com",
"url": "http://gulpjs.com/"
},
"bugs": {
"url": "https://github.com/gulpjs/glob-stream/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Eric Schoffstall",
"email": "yo@contra.io"
},
{
"name": "Blaine Bublitz",
"email": "blaine.bublitz@gmail.com"
}
],
"dependencies": {
"extend": "^3.0.0",
"glob": "^7.1.1",
"glob-parent": "^3.1.0",
"is-negated-glob": "^1.0.0",
"ordered-read-streams": "^1.0.0",
"pumpify": "^1.3.5",
"readable-stream": "^2.1.5",
"remove-trailing-separator": "^1.0.1",
"to-absolute-glob": "^2.0.0",
"unique-stream": "^2.0.2"
},
"deprecated": false,
"description": "A Readable Stream interface over node-glob.",
"devDependencies": {
"eslint": "^1.10.3",
"eslint-config-gulp": "^2.0.0",
"expect": "^1.19.0",
"istanbul": "^0.4.3",
"istanbul-coveralls": "^1.0.3",
"jscs": "^2.4.0",
"jscs-preset-gulp": "^1.0.0",
"mississippi": "^1.2.0",
"mocha": "^2.4.5"
},
"engines": {
"node": ">= 0.10"
},
"files": [
"index.js",
"readable.js",
"LICENSE"
],
"homepage": "https://github.com/gulpjs/glob-stream#readme",
"keywords": [
"glob",
"stream",
"gulp",
"readable",
"fs",
"files"
],
"license": "MIT",
"main": "index.js",
"name": "glob-stream",
"repository": {
"type": "git",
"url": "git+https://github.com/gulpjs/glob-stream.git"
},
"scripts": {
"cover": "istanbul cover _mocha --report lcovonly",
"coveralls": "npm run cover && istanbul-coveralls",
"lint": "eslint . && jscs index.js readable.js test/",
"pretest": "npm run lint",
"test": "mocha --async-only"
},
"version": "6.1.0"
}

View File

@@ -0,0 +1,117 @@
'use strict';
var inherits = require('util').inherits;
var glob = require('glob');
var extend = require('extend');
var Readable = require('readable-stream').Readable;
var globParent = require('glob-parent');
var toAbsoluteGlob = require('to-absolute-glob');
var removeTrailingSeparator = require('remove-trailing-separator');
var globErrMessage1 = 'File not found with singular glob: ';
var globErrMessage2 = ' (if this was purposeful, use `allowEmpty` option)';
function getBasePath(ourGlob, opt) {
return globParent(toAbsoluteGlob(ourGlob, opt));
}
function globIsSingular(glob) {
var globSet = glob.minimatch.set;
if (globSet.length !== 1) {
return false;
}
return globSet[0].every(function isString(value) {
return typeof value === 'string';
});
}
function GlobStream(ourGlob, negatives, opt) {
if (!(this instanceof GlobStream)) {
return new GlobStream(ourGlob, negatives, opt);
}
var ourOpt = extend({}, opt);
Readable.call(this, {
objectMode: true,
highWaterMark: ourOpt.highWaterMark || 16,
});
// Delete `highWaterMark` after inheriting from Readable
delete ourOpt.highWaterMark;
var self = this;
function resolveNegatives(negative) {
return toAbsoluteGlob(negative, ourOpt);
}
var ourNegatives = negatives.map(resolveNegatives);
ourOpt.ignore = ourNegatives;
var cwd = ourOpt.cwd;
var allowEmpty = ourOpt.allowEmpty || false;
// Extract base path from glob
var basePath = ourOpt.base || getBasePath(ourGlob, ourOpt);
// Remove path relativity to make globs make sense
ourGlob = toAbsoluteGlob(ourGlob, ourOpt);
// Delete `root` after all resolving done
delete ourOpt.root;
var globber = new glob.Glob(ourGlob, ourOpt);
this._globber = globber;
var found = false;
globber.on('match', function(filepath) {
found = true;
var obj = {
cwd: cwd,
base: basePath,
path: removeTrailingSeparator(filepath),
};
if (!self.push(obj)) {
globber.pause();
}
});
globber.once('end', function() {
if (allowEmpty !== true && !found && globIsSingular(globber)) {
var err = new Error(globErrMessage1 + ourGlob + globErrMessage2);
return self.destroy(err);
}
self.push(null);
});
function onError(err) {
self.destroy(err);
}
globber.once('error', onError);
}
inherits(GlobStream, Readable);
GlobStream.prototype._read = function() {
this._globber.resume();
};
GlobStream.prototype.destroy = function(err) {
var self = this;
this._globber.abort();
process.nextTick(function() {
if (err) {
self.emit('error', err);
}
self.emit('close');
});
};
module.exports = GlobStream;

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015-2017, Jon Schlinkert
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.

View File

@@ -0,0 +1,103 @@
# is-valid-glob [![NPM version](https://img.shields.io/npm/v/is-valid-glob.svg?style=flat)](https://www.npmjs.com/package/is-valid-glob) [![NPM monthly downloads](https://img.shields.io/npm/dm/is-valid-glob.svg?style=flat)](https://npmjs.org/package/is-valid-glob) [![NPM total downloads](https://img.shields.io/npm/dt/is-valid-glob.svg?style=flat)](https://npmjs.org/package/is-valid-glob) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/is-valid-glob.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/is-valid-glob)
> Return true if a value is a valid glob pattern or patterns.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save is-valid-glob
```
## Usage
This really just checks to make sure that a pattern is either a string or array, and if it's an array it's either empty or consists of only strings.
```js
var isValidGlob = require('is-valid-glob');
isValidGlob('foo/*.js');
//=> true
```
**Valid patterns**
```js
isValidGlob('a');
isValidGlob('a.js');
isValidGlob('*.js');
isValidGlob(['a', 'b']);
//=> all true
```
**Invalid patterns**
```js
isValidGlob();
isValidGlob('');
isValidGlob(null);
isValidGlob(undefined);
isValidGlob(new Buffer('foo'));
isValidGlob(['foo', [[]]]);
isValidGlob(['foo', [['bar']]]);
isValidGlob(['foo', {}]);
isValidGlob({});
isValidGlob([]);
isValidGlob(['']);
//=> all false
```
## About
### Related projects
* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet")
* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/micromatch/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")
* [vinyl-fs](https://www.npmjs.com/package/vinyl-fs): Vinyl adapter for the file system | [homepage](http://github.com/wearefractal/vinyl-fs "Vinyl adapter for the file system")
* [vinyl](https://www.npmjs.com/package/vinyl): Virtual file format. | [homepage](https://github.com/gulpjs/vinyl#readme "Virtual file format.")
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 9 | [jonschlinkert](https://github.com/jonschlinkert) |
| 2 | [contra](https://github.com/contra) |
### Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
### Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
### License
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 21, 2017._

View File

@@ -0,0 +1,21 @@
'use strict';
module.exports = function isValidGlob(glob) {
if (typeof glob === 'string' && glob.length > 0) {
return true;
}
if (Array.isArray(glob)) {
return glob.length !== 0 && every(glob);
}
return false;
};
function every(arr) {
var len = arr.length;
while (len--) {
if (typeof arr[len] !== 'string' || arr[len].length <= 0) {
return false;
}
}
return true;
}

View File

@@ -0,0 +1,101 @@
{
"_from": "is-valid-glob@^1.0.0",
"_id": "is-valid-glob@1.0.0",
"_inBundle": false,
"_integrity": "sha1-Kb8+/3Ab4tTTFdusw5vDn+j2Aao=",
"_location": "/gulp-vinyl-zip/is-valid-glob",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "is-valid-glob@^1.0.0",
"name": "is-valid-glob",
"escapedName": "is-valid-glob",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/gulp-vinyl-zip/vinyl-fs"
],
"_resolved": "https://registry.npmjs.org/is-valid-glob/-/is-valid-glob-1.0.0.tgz",
"_shasum": "29bf3eff701be2d4d315dbacc39bc39fe8f601aa",
"_spec": "is-valid-glob@^1.0.0",
"_where": "/home/nathan/Projects/Upsilon/UpsilonVsCodeLanguageServer/Client/node_modules/gulp-vinyl-zip/node_modules/vinyl-fs",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/is-valid-glob/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "contra",
"url": "http://contra.io"
},
{
"name": "Jon Schlinkert",
"url": "http://twitter.com/jonschlinkert"
}
],
"deprecated": false,
"description": "Return true if a value is a valid glob pattern or patterns.",
"devDependencies": {
"gulp-format-md": "^0.1.12",
"mocha": "^3.4.2"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/jonschlinkert/is-valid-glob",
"keywords": [
"array",
"check",
"glob",
"is",
"match",
"pattern",
"patterns",
"read",
"test",
"valid",
"validate"
],
"license": "MIT",
"main": "index.js",
"name": "is-valid-glob",
"repository": {
"type": "git",
"url": "git+https://github.com/jonschlinkert/is-valid-glob.git"
},
"scripts": {
"test": "mocha"
},
"verb": {
"related": {
"list": [
"is-glob",
"micromatch",
"vinyl-fs",
"vinyl"
]
},
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"lint": {
"reflinks": true
}
},
"version": "1.0.0"
}

View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2014 Artem Medeusheyev
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.

View File

@@ -0,0 +1,65 @@
# ordered-read-streams [![NPM version](https://img.shields.io/npm/v/ordered-read-streams.svg)](http://badge.fury.io/js/ordered-read-streams) [![Build Status](https://travis-ci.org/armed/ordered-read-streams.svg?branch=master)](https://travis-ci.org/armed/ordered-read-streams)
Combines array of streams into one read stream in strict order.
## Installation
`npm install ordered-read-streams`
## Overview
`ordered-read-streams` handles all data/errors from input streams in parallel, but emits data/errors in strict order in which streams are passed to constructor. This is `objectMode = true` stream.
## Example
```js
var through = require('through2');
var Ordered = require('ordered-read-streams');
var s1 = through.obj(function (data, enc, next) {
var self = this;
setTimeout(function () {
self.push(data);
next();
}, 200)
});
var s2 = through.obj(function (data, enc, next) {
var self = this;
setTimeout(function () {
self.push(data);
next();
}, 30)
});
var s3 = through.obj(function (data, enc, next) {
var self = this;
setTimeout(function () {
self.push(data);
next();
}, 100)
});
var streams = new Ordered([s1, s2, s3]);
streams.on('data', function (data) {
console.log(data);
})
s1.write('stream 1');
s1.end();
s2.write('stream 2');
s2.end();
s3.write('stream 3');
s3.end();
```
Ouput will be:
```
stream 1
stream 2
stream 3
```
## Licence
MIT

View File

@@ -0,0 +1,99 @@
var Readable = require('readable-stream/readable');
var util = require('util');
function isReadable(stream) {
if (typeof stream.pipe !== 'function') {
return false;
}
if (!stream.readable) {
return false;
}
if (typeof stream._read !== 'function') {
return false;
}
if (!stream._readableState) {
return false;
}
return true;
}
function addStream (streams, stream) {
if (!isReadable(stream)) {
throw new Error('All input streams must be readable');
}
var self = this;
stream._buffer = [];
stream.on('readable', function () {
var chunk = stream.read();
while (chunk) {
if (this === streams[0]) {
self.push(chunk);
} else {
this._buffer.push(chunk);
}
chunk = stream.read();
}
});
stream.on('end', function () {
for (var stream = streams[0];
stream && stream._readableState.ended;
stream = streams[0]) {
while (stream._buffer.length) {
self.push(stream._buffer.shift());
}
streams.shift();
}
if (!streams.length) {
self.push(null);
}
});
stream.on('error', this.emit.bind(this, 'error'));
streams.push(stream);
}
function OrderedStreams (streams, options) {
if (!(this instanceof(OrderedStreams))) {
return new OrderedStreams(streams, options);
}
streams = streams || [];
options = options || {};
options.objectMode = true;
Readable.call(this, options);
if (!Array.isArray(streams)) {
streams = [streams];
}
if (!streams.length) {
return this.push(null); // no streams, close
}
var addStreamBinded = addStream.bind(this, []);
streams.forEach(function (item) {
if (Array.isArray(item)) {
item.forEach(addStreamBinded);
} else {
addStreamBinded(item);
}
});
}
util.inherits(OrderedStreams, Readable);
OrderedStreams.prototype._read = function () {};
module.exports = OrderedStreams;

View File

@@ -0,0 +1,61 @@
{
"_from": "ordered-read-streams@^1.0.0",
"_id": "ordered-read-streams@1.0.1",
"_inBundle": false,
"_integrity": "sha1-d8DLN8QVJdZBZtmQ/61+xqDhNj4=",
"_location": "/gulp-vinyl-zip/ordered-read-streams",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "ordered-read-streams@^1.0.0",
"name": "ordered-read-streams",
"escapedName": "ordered-read-streams",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/gulp-vinyl-zip/glob-stream"
],
"_resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz",
"_shasum": "77c0cb37c41525d64166d990ffad7ec6a0e1363e",
"_spec": "ordered-read-streams@^1.0.0",
"_where": "/home/nathan/Projects/Upsilon/UpsilonVsCodeLanguageServer/Client/node_modules/gulp-vinyl-zip/node_modules/glob-stream",
"author": {
"name": "Artem Medeusheyev",
"email": "artem.medeusheyev@gmail.com"
},
"bugs": {
"url": "https://github.com/armed/ordered-read-streams/issues"
},
"bundleDependencies": false,
"dependencies": {
"readable-stream": "^2.0.1"
},
"deprecated": false,
"description": "Combines array of streams into one read stream in strict order",
"devDependencies": {
"expect": "^1.20.2",
"jscs": "^1.13.1",
"jshint": "^2.8.0",
"mississippi": "^1.3.0",
"mocha": "^2.2.5",
"pre-commit": "^1.0.10",
"through2": "^2.0.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/armed/ordered-read-streams#readme",
"license": "MIT",
"name": "ordered-read-streams",
"repository": {
"type": "git",
"url": "git+https://github.com/armed/ordered-read-streams.git"
},
"scripts": {
"test": "jscs *.js test/*js && jshint *.js test/*.js && mocha"
},
"version": "1.0.1"
}

View File

@@ -0,0 +1,7 @@
language: node_js
node_js:
- "6"
- "node"
script:
- npm run travis
- npm run travis-ts

View File

@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2014 Jesse Tane <jesse.tane@gmail.com>
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.

View File

@@ -0,0 +1,45 @@
// TypeScript definition for queue
// Provided by Hendrik 'Xendo' Meyer <https://github.com/butterkekstorte>
// Licensed the same as the library itself
/*
Import via
import {IQueue, IQueueWorker} from 'queue';
var queue: IQueue = require('queue');
*/
interface IQueue{
(opts?:IQueueOptions): IQueue
push(...worker:IQueueWorker[]):number
start(callback?:(error?:Error) => void):void
stop():void
end(error?:Error):void
unshift(...worker:IQueueWorker[]):number
splice(index:number, deleteHowMany:number, ...worker:IQueueWorker[]):IQueue
pop():IQueueWorker|void
shift():IQueueWorker|void
slice(begin:number, end?:number):IQueue
reverse():IQueue
indexOf(searchElement:IQueueWorker, fromIndex?:number):number
lastIndexOf(searchElement:IQueueWorker, fromIndex?:number):number
concurrency:number
timeout:number
length:number
on(event:string, callback:IQueueEventCallback):void
}
interface IQueueOptions {
concurrency?:number
timeout?:number
}
interface IQueueWorker {
(cb?:(err?:Error, data?:Object) => void):void
}
interface IQueueEventCallback {
(data?:Object|Error|IQueueWorker, job?:IQueueWorker):void
}
export {IQueue, IQueueEventCallback, IQueueOptions, IQueueWorker};

View File

@@ -0,0 +1,192 @@
var inherits = require('inherits')
var EventEmitter = require('events').EventEmitter
module.exports = Queue
function Queue (options) {
if (!(this instanceof Queue)) {
return new Queue(options)
}
EventEmitter.call(this)
options = options || {}
this.concurrency = options.concurrency || Infinity
this.timeout = options.timeout || 0
this.autostart = options.autostart || false
this.results = options.results || null
this.pending = 0
this.session = 0
this.running = false
this.jobs = []
this.timers = {}
}
inherits(Queue, EventEmitter)
var arrayMethods = [
'pop',
'shift',
'indexOf',
'lastIndexOf'
]
arrayMethods.forEach(function (method) {
Queue.prototype[method] = function () {
return Array.prototype[method].apply(this.jobs, arguments)
}
})
Queue.prototype.slice = function (begin, end) {
this.jobs = this.jobs.slice(begin, end)
return this
}
Queue.prototype.reverse = function () {
this.jobs.reverse()
return this
}
var arrayAddMethods = [
'push',
'unshift',
'splice'
]
arrayAddMethods.forEach(function (method) {
Queue.prototype[method] = function () {
var methodResult = Array.prototype[method].apply(this.jobs, arguments)
if (this.autostart) {
this.start()
}
return methodResult
}
})
Object.defineProperty(Queue.prototype, 'length', {
get: function () {
return this.pending + this.jobs.length
}
})
Queue.prototype.start = function (cb) {
if (cb) {
callOnErrorOrEnd.call(this, cb)
}
this.running = true
if (this.pending >= this.concurrency) {
return
}
if (this.jobs.length === 0) {
if (this.pending === 0) {
done.call(this)
}
return
}
var self = this
var job = this.jobs.shift()
var once = true
var session = this.session
var timeoutId = null
var didTimeout = false
var resultIndex = null
function next (err, result) {
if (once && self.session === session) {
once = false
self.pending--
if (timeoutId !== null) {
delete self.timers[timeoutId]
clearTimeout(timeoutId)
}
if (err) {
self.emit('error', err, job)
} else if (didTimeout === false) {
if (resultIndex !== null) {
self.results[resultIndex] = Array.prototype.slice.call(arguments, 1)
}
self.emit('success', result, job)
}
if (self.session === session) {
if (self.pending === 0 && self.jobs.length === 0) {
done.call(self)
} else if (self.running) {
self.start()
}
}
}
}
if (this.timeout) {
timeoutId = setTimeout(function () {
didTimeout = true
if (self.listeners('timeout').length > 0) {
self.emit('timeout', next, job)
} else {
next()
}
}, this.timeout)
this.timers[timeoutId] = timeoutId
}
if (this.results) {
resultIndex = this.results.length
this.results[resultIndex] = null
}
this.pending++
var promise = job(next)
if (promise && promise.then && typeof promise.then === 'function') {
promise.then(function (result) {
next(null, result)
}).catch(function (err) {
next(err || true)
})
}
if (this.running && this.jobs.length > 0) {
this.start()
}
}
Queue.prototype.stop = function () {
this.running = false
}
Queue.prototype.end = function (err) {
clearTimers.call(this)
this.jobs.length = 0
this.pending = 0
done.call(this, err)
}
function clearTimers () {
for (var key in this.timers) {
var timeoutId = this.timers[key]
delete this.timers[key]
clearTimeout(timeoutId)
}
}
function callOnErrorOrEnd (cb) {
var self = this
this.on('error', onerror)
this.on('end', onend)
function onerror (err) { self.end(err) }
function onend (err) {
self.removeListener('error', onerror)
self.removeListener('end', onend)
cb(err, this.results)
}
}
function done (err) {
this.session++
this.running = false
this.emit('end', err)
}

View File

@@ -0,0 +1,72 @@
{
"_from": "queue@^4.2.1",
"_id": "queue@4.5.0",
"_inBundle": false,
"_integrity": "sha512-DwxpAnqJuoQa+wyDgQuwkSshkhlqIlWEvwvdAY27fDPunZ2cVJzXU4JyjY+5l7zs7oGLaYAQm4MbLOVFAHFBzA==",
"_location": "/gulp-vinyl-zip/queue",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "queue@^4.2.1",
"name": "queue",
"escapedName": "queue",
"rawSpec": "^4.2.1",
"saveSpec": null,
"fetchSpec": "^4.2.1"
},
"_requiredBy": [
"/gulp-vinyl-zip"
],
"_resolved": "https://registry.npmjs.org/queue/-/queue-4.5.0.tgz",
"_shasum": "0f125191a983e3c38fcc0c0c75087d358d0857f4",
"_spec": "queue@^4.2.1",
"_where": "/home/nathan/Projects/Upsilon/UpsilonVsCodeLanguageServer/Client/node_modules/gulp-vinyl-zip",
"author": {
"name": "Jesse Tane",
"email": "jesse.tane@gmail.com"
},
"bugs": {
"url": "https://github.com/jessetane/queue/issues"
},
"bundleDependencies": false,
"dependencies": {
"inherits": "~2.0.0"
},
"deprecated": false,
"description": "asynchronous function queue with adjustable concurrency",
"devDependencies": {
"browserify": "^5.9.1",
"coveralls": "^2.11.2",
"istanbul": "^0.3.2",
"standard": "^8.6.0",
"tape": "^2.14.0",
"typescript": "^1.8.9"
},
"homepage": "https://github.com/jessetane/queue#readme",
"keywords": [
"queue",
"async",
"asynchronous",
"synchronous",
"job",
"task",
"concurrency",
"concurrent"
],
"license": "MIT",
"name": "queue",
"repository": {
"type": "git",
"url": "git+https://github.com/jessetane/queue.git"
},
"scripts": {
"example": "node example",
"lint": "standard",
"test": "standard && node test",
"test-browser": "standard && browserify test/index.js > test/bundle.js && echo \"open test/index.html in your browser\"",
"travis": "standard && istanbul cover test --report lcovonly && cat coverage/lcov.info | coveralls",
"travis-ts": "tsc test/typescript.ts --out /dev/null && echo 'TypeScript compilation passed.'"
},
"version": "4.5.0"
}

View File

@@ -0,0 +1,186 @@
```
____ __ _____ __ _____
/ __ `/ / / / _ \/ / / / _ \
/ /_/ / /_/ / __/ /_/ / __/
\__, /\__,_/\___/\__,_/\___/
/_/
```
Asynchronous function queue with adjustable concurrency.
[![npm](http://img.shields.io/npm/v/queue.svg?style=flat-square)](http://www.npmjs.org/queue)
[![tests](https://img.shields.io/travis/jessetane/queue.svg?style=flat-square&branch=master)](https://travis-ci.org/jessetane/queue)
[![coverage](https://img.shields.io/coveralls/jessetane/queue.svg?style=flat-square&branch=master)](https://coveralls.io/r/jessetane/queue)
This module exports a class `Queue` that implements most of the `Array` API. Pass async functions (ones that accept a callback or return a promise) to an instance's additive array methods. Processing begins when you call `q.start()`.
## Example
`npm run example`
``` javascript
var queue = require('../')
var q = queue()
var results = []
// add jobs using the familiar Array API
q.push(function (cb) {
results.push('two')
cb()
})
q.push(
function (cb) {
results.push('four')
cb()
},
function (cb) {
results.push('five')
cb()
}
)
// jobs can accept a callback or return a promise
q.push(function () {
return new Promise(function (resolve, reject) {
results.push('one')
resolve()
})
})
q.unshift(function (cb) {
results.push('one')
cb()
})
q.splice(2, 0, function (cb) {
results.push('three')
cb()
})
// use the timeout feature to deal with jobs that
// take too long or forget to execute a callback
q.timeout = 100
q.on('timeout', function (next, job) {
console.log('job timed out:', job.toString().replace(/\n/g, ''))
next()
})
q.push(function (cb) {
setTimeout(function () {
console.log('slow job finished')
cb()
}, 200)
})
q.push(function (cb) {
console.log('forgot to execute callback')
})
// get notified when jobs complete
q.on('success', function (result, job) {
console.log('job finished processing:', job.toString().replace(/\n/g, ''))
})
// begin processing, get notified on end / failure
q.start(function (err) {
if (err) throw err
console.log('all done:', results)
})
```
## Install
`npm install queue`
## Test
`npm test`
`npm run test-browser`
## API
### `var q = queue([opts])`
Constructor. `opts` may contain inital values for:
* `q.concurrency`
* `q.timeout`
* `q.autostart`
* `q.results`
## Instance methods
### `q.start([cb])`
cb, if passed, will be called when the queue empties or when an error occurs.
### `q.stop()`
Stops the queue. can be resumed with `q.start()`.
### `q.end([err])`
Stop and empty the queue immediately.
## Instance methods mixed in from `Array`
Mozilla has docs on how these methods work [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array). Note that `slice` does not copy the queue.
### `q.push(element1, ..., elementN)`
### `q.unshift(element1, ..., elementN)`
### `q.splice(index , howMany[, element1[, ...[, elementN]]])`
### `q.pop()`
### `q.shift()`
### `q.slice(begin[, end])`
### `q.reverse()`
### `q.indexOf(searchElement[, fromIndex])`
### `q.lastIndexOf(searchElement[, fromIndex])`
## Properties
### `q.concurrency`
Max number of jobs the queue should process concurrently, defaults to `Infinity`.
### `q.timeout`
Milliseconds to wait for a job to execute its callback.
### `q.autostart`
Ensures the queue is always running if jobs are available. Useful in situations where you are using a queue only for concurrency control.
### `q.results`
An array to set job callback arguments on.
### `q.length`
Jobs pending + jobs to process (readonly).
## Events
### `q.emit('success', result, job)`
After a job executes its callback.
### `q.emit('error', err, job)`
After a job passes an error to its callback.
### `q.emit('timeout', continue, job)`
After `q.timeout` milliseconds have elapsed and a job has not executed its callback.
### `q.emit('end'[, err])`
After all jobs have been processed
## Releases
The latest stable release is published to [npm](http://npmjs.org/queue). Abbreviated changelog below:
* [4.4](https://github.com/jessetane/queue/archive/4.4.0.tar.gz)
* Add results feature
* [4.3](https://github.com/jessetane/queue/archive/4.3.0.tar.gz)
* Add promise support (@kwolfy)
* [4.2](https://github.com/jessetane/queue/archive/4.2.0.tar.gz)
* Unref timers on end
* [4.1](https://github.com/jessetane/queue/archive/4.1.0.tar.gz)
* Add autostart feature
* [4.0](https://github.com/jessetane/queue/archive/4.0.0.tar.gz)
* Change license to MIT
* [3.1.x](https://github.com/jessetane/queue/archive/3.0.6.tar.gz)
* Add .npmignore
* [3.0.x](https://github.com/jessetane/queue/archive/3.0.6.tar.gz)
* Change the default concurrency to `Infinity`
* Allow `q.start()` to accept an optional callback executed on `q.emit('end')`
* [2.x](https://github.com/jessetane/queue/archive/2.2.0.tar.gz)
* Major api changes / not backwards compatible with 1.x
* [1.x](https://github.com/jessetane/queue/archive/1.0.2.tar.gz)
* Early prototype
## License
Copyright © 2014 Jesse Tane <jesse.tane@gmail.com>
This work is free. You can redistribute it and/or modify it under the
terms of the [MIT License](https://opensource.org/licenses/MIT).
See LICENSE for full details.

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015-2016, Jon Schlinkert
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.

View File

@@ -0,0 +1,70 @@
'use strict';
var path = require('path');
var isNegated = require('is-negated-glob');
var isAbsolute = require('is-absolute');
module.exports = function(glob, options) {
// default options
var opts = options || {};
// ensure cwd is absolute
var cwd = path.resolve(opts.cwd ? opts.cwd : process.cwd());
cwd = unixify(cwd);
var rootDir = opts.root;
// if `options.root` is defined, ensure it's absolute
if (rootDir) {
rootDir = unixify(rootDir);
if (process.platform === 'win32' || !isAbsolute(rootDir)) {
rootDir = unixify(path.resolve(rootDir));
}
}
// trim starting ./ from glob patterns
if (glob.slice(0, 2) === './') {
glob = glob.slice(2);
}
// when the glob pattern is only a . use an empty string
if (glob.length === 1 && glob === '.') {
glob = '';
}
// store last character before glob is modified
var suffix = glob.slice(-1);
// check to see if glob is negated (and not a leading negated-extglob)
var ing = isNegated(glob);
glob = ing.pattern;
// make glob absolute
if (rootDir && glob.charAt(0) === '/') {
glob = join(rootDir, glob);
} else if (!isAbsolute(glob) || glob.slice(0, 1) === '\\') {
glob = join(cwd, glob);
}
// if glob had a trailing `/`, re-add it now in case it was removed
if (suffix === '/' && glob.slice(-1) !== '/') {
glob += '/';
}
// re-add leading `!` if it was removed
return ing.negated ? '!' + glob : glob;
};
function unixify(filepath) {
return filepath.replace(/\\/g, '/');
}
function join(dir, glob) {
if (dir.charAt(dir.length - 1) === '/') {
dir = dir.slice(0, -1);
}
if (glob.charAt(0) === '/') {
glob = glob.slice(1);
}
if (!glob) return dir;
return dir + '/' + glob;
}

View File

@@ -0,0 +1,118 @@
{
"_from": "to-absolute-glob@^2.0.0",
"_id": "to-absolute-glob@2.0.2",
"_inBundle": false,
"_integrity": "sha1-GGX0PZ50sIItufFFt4z/fQ98hJs=",
"_location": "/gulp-vinyl-zip/to-absolute-glob",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "to-absolute-glob@^2.0.0",
"name": "to-absolute-glob",
"escapedName": "to-absolute-glob",
"rawSpec": "^2.0.0",
"saveSpec": null,
"fetchSpec": "^2.0.0"
},
"_requiredBy": [
"/gulp-vinyl-zip/glob-stream"
],
"_resolved": "https://registry.npmjs.org/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz",
"_shasum": "1865f43d9e74b0822db9f145b78cff7d0f7c849b",
"_spec": "to-absolute-glob@^2.0.0",
"_where": "/home/nathan/Projects/Upsilon/UpsilonVsCodeLanguageServer/Client/node_modules/gulp-vinyl-zip/node_modules/glob-stream",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/to-absolute-glob/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Blaine Bublitz",
"email": "blaine.bublitz@gmail.com",
"url": "https://twitter.com/BlaineBublitz"
},
{
"name": "Brian Woodward",
"email": "brian.woodward@gmail.com",
"url": "https://github.com/doowb"
},
{
"name": "Erik Kemperman",
"url": "https://github.com/erikkemperman"
},
{
"name": "Jon Schlinkert",
"email": "jon.schlinkert@sellside.com",
"url": "http://twitter.com/jonschlinkert"
}
],
"dependencies": {
"is-absolute": "^1.0.0",
"is-negated-glob": "^1.0.0"
},
"deprecated": false,
"description": "Make a glob pattern absolute, ensuring that negative globs and patterns with trailing slashes are correctly handled.",
"devDependencies": {
"gulp-format-md": "^0.1.11",
"mocha": "^3.0.2"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/jonschlinkert/to-absolute-glob",
"keywords": [
"absolute",
"file",
"filepath",
"glob",
"negate",
"negative",
"path",
"pattern",
"resolve",
"to"
],
"license": "MIT",
"main": "index.js",
"name": "to-absolute-glob",
"repository": {
"type": "git",
"url": "git+https://github.com/jonschlinkert/to-absolute-glob.git"
},
"scripts": {
"test": "mocha"
},
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"lint": {
"reflinks": true
},
"related": {
"list": [
"has-glob",
"is-glob",
"is-valid-glob"
]
},
"reflinks": [
"verb",
"verb-generate-readme"
]
},
"version": "2.0.2"
}

View File

@@ -0,0 +1,155 @@
# to-absolute-glob [![NPM version](https://img.shields.io/npm/v/to-absolute-glob.svg?style=flat)](https://www.npmjs.com/package/to-absolute-glob) [![NPM downloads](https://img.shields.io/npm/dm/to-absolute-glob.svg?style=flat)](https://npmjs.org/package/to-absolute-glob) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/to-absolute-glob.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/to-absolute-glob) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/to-absolute-glob.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/to-absolute-glob)
> Make a glob pattern absolute, ensuring that negative globs and patterns with trailing slashes are correctly handled.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save to-absolute-glob
```
## Usage
```js
var toAbsGlob = require('to-absolute-glob');
toAbsGlob('a/*.js');
//=> '/dev/foo/a/*.js'
```
## Examples
Given the current project folder (cwd) is `/dev/foo/`:
**makes a path absolute**
```js
toAbsGlob('a');
//=> '/dev/foo/a'
```
**makes a glob absolute**
```js
toAbsGlob('a/*.js');
//=> '/dev/foo/a/*.js'
```
**retains trailing slashes**
```js
toAbsGlob('a/*/');
//=> '/dev/foo/a/*/'
```
**retains trailing slashes with cwd**
```js
toAbsGlob('./fixtures/whatsgoingon/*/', {cwd: __dirname});
//=> '/dev/foo/'
```
**makes a negative glob absolute**
```js
toAbsGlob('!a/*.js');
//=> '!/dev/foo/a/*.js'
```
**from a cwd**
```js
toAbsGlob('a/*.js', {cwd: 'foo'});
//=> '/dev/foo/foo/a/*.js'
```
**makes a negative glob absolute from a cwd**
```js
toAbsGlob('!a/*.js', {cwd: 'foo'});
//=> '!/dev/foo/foo/a/*.js'
```
**from a root path**
```js
toAbsGlob('/a/*.js', {root: 'baz'});
//=> '/dev/foo/baz/a/*.js'
```
**from a root slash**
```js
toAbsGlob('/a/*.js', {root: '/'});
//=> '/dev/foo/a/*.js'
```
**from a negative root path**
```js
toAbsGlob('!/a/*.js', {root: 'baz'});
//=> '!/dev/foo/baz/a/*.js'
```
**from a negative root slash**
```js
toAbsGlob('!/a/*.js', {root: '/'});
//=> '!/dev/foo/a/*.js'
```
## About
### Related projects
* [has-glob](https://www.npmjs.com/package/has-glob): Returns `true` if an array has a glob pattern. | [homepage](https://github.com/jonschlinkert/has-glob "Returns `true` if an array has a glob pattern.")
* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet")
* [is-valid-glob](https://www.npmjs.com/package/is-valid-glob): Return true if a value is a valid glob pattern or patterns. | [homepage](https://github.com/jonschlinkert/is-valid-glob "Return true if a value is a valid glob pattern or patterns.")
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### Contributors
| **Commits** | **Contributor**<br/> |
| --- | --- |
| 16 | [doowb](https://github.com/doowb) |
| 15 | [jonschlinkert](https://github.com/jonschlinkert) |
| 1 | [phated](https://github.com/phated) |
| 1 | [erikkemperman](https://github.com/erikkemperman) |
### Building docs
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
```sh
$ npm install -g verb verb-generate-readme && verb
```
### Running tests
Install dev dependencies:
```sh
$ npm install -d && npm test
```
### Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
### License
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/jonschlinkert/to-absolute-glob/blob/master/LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 17, 2016._

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2013-2017 Blaine Bublitz <blaine.bublitz@gmail.com>, Eric Schoffstall <yo@contra.io> and other contributors
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.

View File

@@ -0,0 +1,341 @@
<p align="center">
<a href="http://gulpjs.com">
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
</a>
</p>
# vinyl-fs
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
[Vinyl][vinyl] adapter for the file system.
## What is Vinyl?
[Vinyl][vinyl] is a very simple metadata object that describes a file. When you think of a file, two attributes come to mind: `path` and `contents`. These are the main attributes on a [Vinyl][vinyl] object. A file does not necessarily represent something on your computers file system. You have files on S3, FTP, Dropbox, Box, CloudThingly.io and other services. [Vinyl][vinyl] can be used to describe files from all of these sources.
## What is a Vinyl Adapter?
While Vinyl provides a clean way to describe a file, we now need a way to access these files. Each file source needs what we call a "Vinyl adapter". A Vinyl adapter simply exposes a `src(globs)` and a `dest(folder)` method. Each return a stream. The `src` stream produces Vinyl objects, and the `dest` stream consumes Vinyl objects. Vinyl adapters can expose extra methods that might be specific to their input/output medium, such as the `symlink` method `vinyl-fs` provides.
## Usage
```javascript
var map = require('map-stream');
var vfs = require('vinyl-fs');
var log = function(file, cb) {
console.log(file.path);
cb(null, file);
};
vfs.src(['./js/**/*.js', '!./js/vendor/*.js'])
.pipe(map(log))
.pipe(vfs.dest('./output'));
```
## API
### `src(globs[, options])`
Takes a glob string or an array of glob strings as the first argument and an options object as the second.
Returns a stream of [vinyl] `File` objects.
__Note: UTF-8 BOM will be removed from all UTF-8 files read with `.src` unless disabled in the options.__
#### Globs
Globs are executed in order, so negations should follow positive globs.
For example:
```js
fs.src(['!b*', '*'])
```
would not exclude any files, but the following would exclude all files starting with "b":
```js
fs.src(['*', '!b*'])
```
#### Options
- Values passed to the options must be of the expected type, otherwise they will be ignored.
- All options can be passed a function instead of a value. The function will be called with the [vinyl] `File` object as its only argument and must return a value of the expected type for that option.
##### `options.buffer`
Whether or not you want to buffer the file contents into memory. Setting to `false` will make `file.contents` a paused Stream.
Type: `Boolean`
Default: `true`
##### `options.read`
Whether or not you want the file to be read at all. Useful for stuff like removing files. Setting to `false` will make `file.contents = null` and will disable writing the file to disk via `.dest()`.
Type: `Boolean`
Default: `true`
##### `options.since`
Only streams files that have been modified since the time specified.
Type: `Date` or `Number`
Default: `undefined`
##### `options.removeBOM`
Causes the BOM to be removed on UTF-8 encoded files. Set to `false` if you need the BOM for some reason.
Type: `Boolean`
Default: `true`
##### `options.sourcemaps`
Enables sourcemap support on files passed through the stream. Will load inline sourcemaps and resolve sourcemap links from files.
Type: `Boolean`
Default: `false`
##### `options.resolveSymlinks`
Whether or not to recursively resolve symlinks to their targets. Set to `false` to preserve them as symlinks and make `file.symlink` equal the original symlink's target path.
Type: `Boolean`
Default: `true`
##### `options.dot`
Whether or not you want globs to match on dot files (e.g. `.gitignore`).
__Note: This option is not resolved from a function because it is passed verbatim to node-glob.__
Type: `Boolean`
Default: `false`
##### other
Any glob-related options are documented in [glob-stream] and [node-glob] and are forwarded verbatim.
### `dest(folder[, options])`
Takes a folder path string or a function as the first argument and an options object as the second. If given a function, it will be called with each [vinyl] `File` object and must return a folder path.
Returns a stream that accepts [vinyl] `File` objects, writes them to disk at the folder/cwd specified, and passes them downstream so you can keep piping these around.
Once the file is written to disk, an attempt is made to determine if the `stat.mode`, `stat.mtime` and `stat.atime` of the [vinyl] `File` object differ from the file on the filesystem.
If they differ and the running process owns the file, the corresponding filesystem metadata is updated.
If they don't differ or the process doesn't own the file, the attempt is skipped silently.
__This functionality is disabled on Windows operating systems or any other OS that doesn't support `process.getuid` or `process.geteuid` in node. This is due to Windows having very unexpected results through usage of `fs.fchmod` and `fs.futimes`.__
__Note: The `fs.futimes()` method internally converts `stat.mtime` and `stat.atime` timestamps to seconds; this division by `1000` may cause some loss of precision in 32-bit Node.js.__
If the file has a `symlink` attribute specifying a target path, then a symlink will be created.
__Note: The file will be modified after being written to this stream.__
- `cwd`, `base`, and `path` will be overwritten to match the folder.
- `stat` will be updated to match the file on the filesystem.
- `contents` will have it's position reset to the beginning if it is a stream.
#### Options
- Values passed to the options must be of the expected type, otherwise they will be ignored.
- All options can be passed a function instead of a value. The function will be called with the [vinyl] `File` object as its only argument and must return a value of the expected type for that option.
##### `options.cwd`
The working directory the folder is relative to.
Type: `String`
Default: `process.cwd()`
##### `options.mode`
The mode the files should be created with. This option is only resolved if the [vinyl] `File` is not symbolic.
Type: `Number`
Default: The `mode` of the input file (`file.stat.mode`) if any, or the process mode if the input file has no `mode` property.
##### `options.dirMode`
The mode directories should be created with.
Type: `Number`
Default: The process `mode`.
##### `options.overwrite`
Whether or not existing files with the same path should be overwritten.
Type: `Boolean`
Default: `true` (always overwrite existing files)
##### `options.append`
Whether or not new data should be appended after existing file contents (if any).
Type: `Boolean`
Default: `false` (always replace existing contents, if any)
##### `options.sourcemaps`
Enables sourcemap support on files passed through the stream. Will write inline soucemaps if specified as `true`.
Specifying a `String` path will write external sourcemaps at the given path.
Examples:
```js
// Write as inline comments
vfs.dest('./', { sourcemaps: true });
// Write as files in the same folder
vfs.dest('./', { sourcemaps: '.' });
```
Type: `Boolean` or `String`
Default: `undefined` (do not write sourcemaps)
##### `options.relativeSymlinks`
When creating a symlink, whether or not the created symlink should be relative. If `false`, the symlink will be absolute.
__Note: This option will be ignored if a `junction` is being created, as they must be absolute.__
Type: `Boolean`
Default: `false`
##### `options.useJunctions`
When creating a symlink, whether or not a directory symlink should be created as a `junction`.
This option is only relevant on Windows and ignored elsewhere. Please refer to the [Symbolic Links on Windows][symbolic-caveats] section below.
Type: `Boolean`
Default: `true`
### `symlink(folder[, options])`
Takes a folder path string or a function as the first argument and an options object as the second. If given a function, it will be called with each [vinyl] `File` object and must return a folder path.
Returns a stream that accepts [vinyl] `File` objects, creates a symbolic link (i.e. symlink) at the folder/cwd specified, and passes them downstream so you can keep piping these around.
__Note: The file will be modified after being written to this stream.__
- `cwd`, `base`, and `path` will be overwritten to match the folder.
- `stat` will be updated to match the symlink on the filesystem.
- `contents` will be set to `null`.
- `symlink` will be added or replaced to be the original path.
__Note: On Windows, directory links are created using Junctions by default. Use the `useJunctions` option to disable this behavior.__
#### Options
- Values passed to the options must be of the expected type, otherwise they will be ignored.
- All options can be passed a function instead of a value. The function will be called with the [vinyl] `File` object as its only argument and must return a value of the expected type for that option.
##### `options.cwd`
The working directory the folder is relative to.
Type: `String`
Default: `process.cwd()`
##### `options.dirMode`
The mode directories should be created with.
Type: `Number`
Default: The process mode.
##### `options.overwrite`
Whether or not existing files with the same path should be overwritten.
Type: `Boolean`
Default: `true` (always overwrite existing files)
##### `options.relativeSymlinks`
Whether or not the created symlinks should be relative. If `false`, the symlink will be absolute.
__Note: This option will be ignored if a `junction` is being created, as they must be absolute.__
Type: `Boolean`
Default: `false`
##### `options.useJunctions`
When creating a symlink, whether or not a directory symlink should be created as a `junction`.
This option is only relevant on Windows and ignored elsewhere. Please refer to the [Symbolic Links on Windows][symbolic-caveats] section below.
Type: `Boolean`
Default: `true`
#### Symbolic Links on Windows
When creating symbolic links on Windows, we pass a `type` argument to Node's
`fs` module which specifies the kind of target we link to (one of `'file'`,
`'dir'` or `'junction'`). Specifically, this will be `'file'` when the target
is a regular file, `'junction'` if the target is a directory, or `'dir'` if
the target is a directory and the user overrides the `useJunctions` option
default.
However, if the user tries to make a "dangling" link (pointing to a non-existent
target) we won't be able to determine automatically which type we should use.
In these cases, `vinyl-fs` will behave slightly differently depending on
whether the dangling link is being created via `symlink()` or via `dest()`.
For dangling links created via `symlink()`, the incoming vinyl represents the
target and so we will look to its stats to guess the desired type. In
particular, if `isDirectory()` returns false then we'll create a `'file'` type
link, otherwise we will create a `'junction'` or a `'dir'` type link depending
on the value of the `useJunctions` option.
For dangling links created via `dest()`, the incoming vinyl represents the link -
typically read off disk via `src()` with the `resolveSymlinks` option set to
false. In this case, we won't be able to make any reasonable guess as to the
type of link and we default to using `'file'`, which may cause unexpected behavior
if you are creating a "dangling" link to a directory. It is advised to avoid this
scenario.
[symbolic-caveats]: #symbolic-links-on-windows
[glob-stream]: https://github.com/gulpjs/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
[downloads-image]: http://img.shields.io/npm/dm/vinyl-fs.svg
[npm-url]: https://www.npmjs.com/package/vinyl-fs
[npm-image]: http://img.shields.io/npm/v/vinyl-fs.svg
[travis-url]: https://travis-ci.org/gulpjs/vinyl-fs
[travis-image]: http://img.shields.io/travis/gulpjs/vinyl-fs.svg?label=travis-ci
[appveyor-url]: https://ci.appveyor.com/project/gulpjs/vinyl-fs
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/vinyl-fs.svg?label=appveyor
[coveralls-url]: https://coveralls.io/r/gulpjs/vinyl-fs
[coveralls-image]: http://img.shields.io/coveralls/gulpjs/vinyl-fs/master.svg
[gitter-url]: https://gitter.im/gulpjs/gulp
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg

View File

@@ -0,0 +1,7 @@
'use strict';
module.exports = {
src: require('./lib/src'),
dest: require('./lib/dest'),
symlink: require('./lib/symlink'),
};

View File

@@ -0,0 +1,6 @@
'use strict';
module.exports = {
MASK_MODE: parseInt('7777', 8),
DEFAULT_FILE_MODE: parseInt('0666', 8),
};

View File

@@ -0,0 +1,45 @@
'use strict';
var lead = require('lead');
var pumpify = require('pumpify');
var mkdirpStream = require('fs-mkdirp-stream');
var createResolver = require('resolve-options');
var config = require('./options');
var prepare = require('./prepare');
var sourcemap = require('./sourcemap');
var writeContents = require('./write-contents');
var folderConfig = {
outFolder: {
type: 'string',
},
};
function dest(outFolder, opt) {
if (!outFolder) {
throw new Error('Invalid dest() folder argument.' +
' Please specify a non-empty string or a function.');
}
var optResolver = createResolver(config, opt);
var folderResolver = createResolver(folderConfig, { outFolder: outFolder });
function dirpath(file, callback) {
var dirMode = optResolver.resolve('dirMode', file);
callback(null, file.dirname, dirMode);
}
var saveStream = pumpify.obj(
prepare(folderResolver, optResolver),
sourcemap(optResolver),
mkdirpStream.obj(dirpath),
writeContents(optResolver)
);
// Sink the output stream to start flowing
return lead(saveStream);
}
module.exports = dest;

View File

@@ -0,0 +1,41 @@
'use strict';
var config = {
cwd: {
type: 'string',
default: process.cwd,
},
mode: {
type: 'number',
default: function(file) {
return file.stat ? file.stat.mode : null;
},
},
dirMode: {
type: 'number',
},
overwrite: {
type: 'boolean',
default: true,
},
append: {
type: 'boolean',
default: false,
},
sourcemaps: {
type: ['string', 'boolean'],
default: false,
},
// Symlink options
relativeSymlinks: {
type: 'boolean',
default: false,
},
// This option is ignored on non-Windows platforms
useJunctions: {
type: 'boolean',
default: true,
},
};
module.exports = config;

View File

@@ -0,0 +1,48 @@
'use strict';
var path = require('path');
var fs = require('graceful-fs');
var Vinyl = require('vinyl');
var through = require('through2');
function prepareWrite(folderResolver, optResolver) {
if (!folderResolver) {
throw new Error('Invalid output folder');
}
function normalize(file, enc, cb) {
if (!Vinyl.isVinyl(file)) {
return cb(new Error('Received a non-Vinyl object in `dest()`'));
}
// TODO: Remove this after people upgrade vinyl/transition from gulp-util
if (typeof file.isSymbolic !== 'function') {
file = new Vinyl(file);
}
var outFolderPath = folderResolver.resolve('outFolder', file);
if (!outFolderPath) {
return cb(new Error('Invalid output folder'));
}
var cwd = path.resolve(optResolver.resolve('cwd', file));
var basePath = path.resolve(cwd, outFolderPath);
var writePath = path.resolve(basePath, file.relative);
// Wire up new properties
file.cwd = cwd;
file.base = basePath;
file.path = writePath;
if (!file.isSymbolic()) {
var mode = optResolver.resolve('mode', file);
file.stat = (file.stat || new fs.Stats());
file.stat.mode = mode;
}
cb(null, file);
}
return through.obj(normalize);
}
module.exports = prepareWrite;

View File

@@ -0,0 +1,38 @@
'use strict';
var through = require('through2');
var sourcemap = require('vinyl-sourcemap');
function sourcemapStream(optResolver) {
function saveSourcemap(file, enc, callback) {
var self = this;
var srcMap = optResolver.resolve('sourcemaps', file);
if (!srcMap) {
return callback(null, file);
}
var srcMapLocation = (typeof srcMap === 'string' ? srcMap : undefined);
sourcemap.write(file, srcMapLocation, onWrite);
function onWrite(sourcemapErr, updatedFile, sourcemapFile) {
if (sourcemapErr) {
return callback(sourcemapErr);
}
self.push(updatedFile);
if (sourcemapFile) {
self.push(sourcemapFile);
}
callback();
}
}
return through.obj(saveSourcemap);
}
module.exports = sourcemapStream;

View File

@@ -0,0 +1,59 @@
'use strict';
var through = require('through2');
var writeDir = require('./write-dir');
var writeStream = require('./write-stream');
var writeBuffer = require('./write-buffer');
var writeSymbolicLink = require('./write-symbolic-link');
var fo = require('../../file-operations');
function writeContents(optResolver) {
function writeFile(file, enc, callback) {
// Write it as a symlink
if (file.isSymbolic()) {
return writeSymbolicLink(file, optResolver, onWritten);
}
// If directory then mkdirp it
if (file.isDirectory()) {
return writeDir(file, optResolver, onWritten);
}
// Stream it to disk yo
if (file.isStream()) {
return writeStream(file, optResolver, onWritten);
}
// Write it like normal
if (file.isBuffer()) {
return writeBuffer(file, optResolver, onWritten);
}
// If no contents then do nothing
if (file.isNull()) {
return onWritten();
}
// This is invoked by the various writeXxx modules when they've finished
// writing the contents.
function onWritten(writeErr) {
var flags = fo.getFlags({
overwrite: optResolver.resolve('overwrite', file),
append: optResolver.resolve('append', file),
});
if (fo.isFatalOverwriteError(writeErr, flags)) {
return callback(writeErr);
}
callback(null, file);
}
}
return through.obj(writeFile);
}
module.exports = writeContents;

View File

@@ -0,0 +1,31 @@
'use strict';
var fo = require('../../file-operations');
function writeBuffer(file, optResolver, onWritten) {
var flags = fo.getFlags({
overwrite: optResolver.resolve('overwrite', file),
append: optResolver.resolve('append', file),
});
var opt = {
mode: file.stat.mode,
flags: flags,
};
fo.writeFile(file.path, file.contents, opt, onWriteFile);
function onWriteFile(writeErr, fd) {
if (writeErr) {
return fo.closeFd(writeErr, fd, onWritten);
}
fo.updateMetadata(fd, file, onUpdate);
function onUpdate(updateErr) {
fo.closeFd(updateErr, fd, onWritten);
}
}
}
module.exports = writeBuffer;

View File

@@ -0,0 +1,51 @@
'use strict';
var fs = require('graceful-fs');
var mkdirp = require('fs-mkdirp-stream/mkdirp');
var fo = require('../../file-operations');
function writeDir(file, optResolver, onWritten) {
mkdirp(file.path, file.stat.mode, onMkdirp);
function onMkdirp(mkdirpErr) {
if (mkdirpErr) {
return onWritten(mkdirpErr);
}
fs.open(file.path, 'r', onOpen);
}
function onOpen(openErr, fd) {
// If we don't have access, just move along
if (isInaccessible(openErr)) {
return fo.closeFd(null, fd, onWritten);
}
if (openErr) {
return fo.closeFd(openErr, fd, onWritten);
}
fo.updateMetadata(fd, file, onUpdate);
function onUpdate(updateErr) {
fo.closeFd(updateErr, fd, onWritten);
}
}
}
function isInaccessible(err) {
if (!err) {
return false;
}
if (err.code === 'EACCES') {
return true;
}
return false;
}
module.exports = writeDir;

View File

@@ -0,0 +1,62 @@
'use strict';
var fo = require('../../file-operations');
var readStream = require('../../src/read-contents/read-stream');
function writeStream(file, optResolver, onWritten) {
var flags = fo.getFlags({
overwrite: optResolver.resolve('overwrite', file),
append: optResolver.resolve('append', file),
});
var opt = {
mode: file.stat.mode,
// TODO: need to test this
flags: flags,
};
// TODO: is this the best API?
var outStream = fo.createWriteStream(file.path, opt, onFlush);
file.contents.once('error', onComplete);
outStream.once('error', onComplete);
outStream.once('finish', onComplete);
// TODO: should this use a clone?
file.contents.pipe(outStream);
function onComplete(streamErr) {
// Cleanup event handlers before closing
file.contents.removeListener('error', onComplete);
outStream.removeListener('error', onComplete);
outStream.removeListener('finish', onComplete);
// Need to guarantee the fd is closed before forwarding the error
outStream.once('close', onClose);
outStream.end();
function onClose(closeErr) {
onWritten(streamErr || closeErr);
}
}
// Cleanup
function onFlush(fd, callback) {
// TODO: removing this before readStream because it replaces the stream
file.contents.removeListener('error', onComplete);
// TODO: this is doing sync stuff & the callback seems unnecessary
// TODO: Replace the contents stream or use a clone?
readStream(file, complete);
function complete() {
if (typeof fd !== 'number') {
return callback();
}
fo.updateMetadata(fd, file, callback);
}
}
}
module.exports = writeStream;

View File

@@ -0,0 +1,77 @@
'use strict';
var os = require('os');
var path = require('path');
var fo = require('../../file-operations');
var isWindows = (os.platform() === 'win32');
function writeSymbolicLink(file, optResolver, onWritten) {
if (!file.symlink) {
return onWritten(new Error('Missing symlink property on symbolic vinyl'));
}
var isRelative = optResolver.resolve('relativeSymlinks', file);
var flags = fo.getFlags({
overwrite: optResolver.resolve('overwrite', file),
append: optResolver.resolve('append', file),
});
if (!isWindows) {
// On non-Windows, just use 'file'
return createLinkWithType('file');
}
fo.reflectStat(file.symlink, file, onReflect);
function onReflect(statErr) {
if (statErr && statErr.code !== 'ENOENT') {
return onWritten(statErr);
}
// This option provides a way to create a Junction instead of a
// Directory symlink on Windows. This comes with the following caveats:
// * NTFS Junctions cannot be relative.
// * NTFS Junctions MUST be directories.
// * NTFS Junctions must be on the same file system.
// * Most products CANNOT detect a directory is a Junction:
// This has the side effect of possibly having a whole directory
// deleted when a product is deleting the Junction directory.
// For example, JetBrains product lines will delete the entire contents
// of the TARGET directory because the product does not realize it's
// a symlink as the JVM and Node return false for isSymlink.
// This function is Windows only, so we don't need to check again
var useJunctions = optResolver.resolve('useJunctions', file);
var dirType = useJunctions ? 'junction' : 'dir';
// Dangling links are always 'file'
var type = !statErr && file.isDirectory() ? dirType : 'file';
createLinkWithType(type);
}
function createLinkWithType(type) {
// This is done after prepare() to use the adjusted file.base property
if (isRelative && type !== 'junction') {
file.symlink = path.relative(file.base, file.symlink);
}
var opts = {
flags: flags,
type: type,
};
fo.symlink(file.symlink, file.path, opts, onSymlink);
function onSymlink(symlinkErr) {
if (symlinkErr) {
return onWritten(symlinkErr);
}
fo.reflectLinkStat(file.path, file, onWritten);
}
}
}
module.exports = writeSymbolicLink;

View File

@@ -0,0 +1,496 @@
'use strict';
var util = require('util');
var fs = require('graceful-fs');
var assign = require('object.assign');
var date = require('value-or-function').date;
var Writable = require('readable-stream').Writable;
var constants = require('./constants');
var APPEND_MODE_REGEXP = /a/;
function closeFd(propagatedErr, fd, callback) {
if (typeof fd !== 'number') {
return callback(propagatedErr);
}
fs.close(fd, onClosed);
function onClosed(closeErr) {
if (propagatedErr || closeErr) {
return callback(propagatedErr || closeErr);
}
callback();
}
}
function isValidUnixId(id) {
if (typeof id !== 'number') {
return false;
}
if (id < 0) {
return false;
}
return true;
}
function getFlags(options) {
var flags = !options.append ? 'w' : 'a';
if (!options.overwrite) {
flags += 'x';
}
return flags;
}
function isFatalOverwriteError(err, flags) {
if (!err) {
return false;
}
if (err.code === 'EEXIST' && flags[1] === 'x') {
// Handle scenario for file overwrite failures.
return false;
}
// Otherwise, this is a fatal error
return true;
}
function isFatalUnlinkError(err) {
if (!err || err.code === 'ENOENT') {
return false;
}
return true;
}
function getModeDiff(fsMode, vinylMode) {
var modeDiff = 0;
if (typeof vinylMode === 'number') {
modeDiff = (vinylMode ^ fsMode) & constants.MASK_MODE;
}
return modeDiff;
}
function getTimesDiff(fsStat, vinylStat) {
var mtime = date(vinylStat.mtime) || 0;
if (!mtime) {
return;
}
var atime = date(vinylStat.atime) || 0;
if (+mtime === +fsStat.mtime &&
+atime === +fsStat.atime) {
return;
}
if (!atime) {
atime = date(fsStat.atime) || undefined;
}
var timesDiff = {
mtime: vinylStat.mtime,
atime: atime,
};
return timesDiff;
}
function getOwnerDiff(fsStat, vinylStat) {
if (!isValidUnixId(vinylStat.uid) &&
!isValidUnixId(vinylStat.gid)) {
return;
}
if ((!isValidUnixId(fsStat.uid) && !isValidUnixId(vinylStat.uid)) ||
(!isValidUnixId(fsStat.gid) && !isValidUnixId(vinylStat.gid))) {
return;
}
var uid = fsStat.uid; // Default to current uid.
if (isValidUnixId(vinylStat.uid)) {
uid = vinylStat.uid;
}
var gid = fsStat.gid; // Default to current gid.
if (isValidUnixId(vinylStat.gid)) {
gid = vinylStat.gid;
}
if (uid === fsStat.uid &&
gid === fsStat.gid) {
return;
}
var ownerDiff = {
uid: uid,
gid: gid,
};
return ownerDiff;
}
function isOwner(fsStat) {
var hasGetuid = (typeof process.getuid === 'function');
var hasGeteuid = (typeof process.geteuid === 'function');
// If we don't have either, assume we don't have permissions.
// This should only happen on Windows.
// Windows basically noops fchmod and errors on futimes called on directories.
if (!hasGeteuid && !hasGetuid) {
return false;
}
var uid;
if (hasGeteuid) {
uid = process.geteuid();
} else {
uid = process.getuid();
}
if (fsStat.uid !== uid && uid !== 0) {
return false;
}
return true;
}
function reflectStat(path, file, callback) {
// Set file.stat to the reflect current state on disk
fs.stat(path, onStat);
function onStat(statErr, stat) {
if (statErr) {
return callback(statErr);
}
file.stat = stat;
callback();
}
}
function reflectLinkStat(path, file, callback) {
// Set file.stat to the reflect current state on disk
fs.lstat(path, onLstat);
function onLstat(lstatErr, stat) {
if (lstatErr) {
return callback(lstatErr);
}
file.stat = stat;
callback();
}
}
function updateMetadata(fd, file, callback) {
fs.fstat(fd, onStat);
function onStat(statErr, stat) {
if (statErr) {
return callback(statErr);
}
// Check if mode needs to be updated
var modeDiff = getModeDiff(stat.mode, file.stat.mode);
// Check if atime/mtime need to be updated
var timesDiff = getTimesDiff(stat, file.stat);
// Check if uid/gid need to be updated
var ownerDiff = getOwnerDiff(stat, file.stat);
// Set file.stat to the reflect current state on disk
assign(file.stat, stat);
// Nothing to do
if (!modeDiff && !timesDiff && !ownerDiff) {
return callback();
}
// Check access, `futimes`, `fchmod` & `fchown` only work if we own
// the file, or if we are effectively root (`fchown` only when root).
if (!isOwner(stat)) {
return callback();
}
if (modeDiff) {
return mode();
}
if (timesDiff) {
return times();
}
owner();
function mode() {
var mode = stat.mode ^ modeDiff;
fs.fchmod(fd, mode, onFchmod);
function onFchmod(fchmodErr) {
if (!fchmodErr) {
file.stat.mode = mode;
}
if (timesDiff) {
return times(fchmodErr);
}
if (ownerDiff) {
return owner(fchmodErr);
}
callback(fchmodErr);
}
}
function times(propagatedErr) {
fs.futimes(fd, timesDiff.atime, timesDiff.mtime, onFutimes);
function onFutimes(futimesErr) {
if (!futimesErr) {
file.stat.atime = timesDiff.atime;
file.stat.mtime = timesDiff.mtime;
}
if (ownerDiff) {
return owner(propagatedErr || futimesErr);
}
callback(propagatedErr || futimesErr);
}
}
function owner(propagatedErr) {
fs.fchown(fd, ownerDiff.uid, ownerDiff.gid, onFchown);
function onFchown(fchownErr) {
if (!fchownErr) {
file.stat.uid = ownerDiff.uid;
file.stat.gid = ownerDiff.gid;
}
callback(propagatedErr || fchownErr);
}
}
}
}
function symlink(srcPath, destPath, opts, callback) {
// Because fs.symlink does not allow atomic overwrite option with flags, we
// delete and recreate if the link already exists and overwrite is true.
if (opts.flags === 'w') {
// TODO What happens when we call unlink with windows junctions?
fs.unlink(destPath, onUnlink);
} else {
fs.symlink(srcPath, destPath, opts.type, onSymlink);
}
function onUnlink(unlinkErr) {
if (isFatalUnlinkError(unlinkErr)) {
return callback(unlinkErr);
}
fs.symlink(srcPath, destPath, opts.type, onSymlink);
}
function onSymlink(symlinkErr) {
if (isFatalOverwriteError(symlinkErr, opts.flags)) {
return callback(symlinkErr);
}
callback();
}
}
/*
Custom writeFile implementation because we need access to the
file descriptor after the write is complete.
Most of the implementation taken from node core.
*/
function writeFile(filepath, data, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
if (!Buffer.isBuffer(data)) {
return callback(new TypeError('Data must be a Buffer'));
}
if (!options) {
options = {};
}
// Default the same as node
var mode = options.mode || constants.DEFAULT_FILE_MODE;
var flags = options.flags || 'w';
var position = APPEND_MODE_REGEXP.test(flags) ? null : 0;
fs.open(filepath, flags, mode, onOpen);
function onOpen(openErr, fd) {
if (openErr) {
return onComplete(openErr);
}
fs.write(fd, data, 0, data.length, position, onComplete);
function onComplete(writeErr) {
callback(writeErr, fd);
}
}
}
function createWriteStream(path, options, flush) {
return new WriteStream(path, options, flush);
}
// Taken from node core and altered to receive a flush function and simplified
// To be used for cleanup (like updating times/mode/etc)
function WriteStream(path, options, flush) {
// Not exposed so we can avoid the case where someone doesn't use `new`
if (typeof options === 'function') {
flush = options;
options = null;
}
options = options || {};
Writable.call(this, options);
this.flush = flush;
this.path = path;
this.mode = options.mode || constants.DEFAULT_FILE_MODE;
this.flags = options.flags || 'w';
// Used by node's `fs.WriteStream`
this.fd = null;
this.start = null;
this.open();
// Dispose on finish.
this.once('finish', this.close);
}
util.inherits(WriteStream, Writable);
WriteStream.prototype.open = function() {
var self = this;
fs.open(this.path, this.flags, this.mode, onOpen);
function onOpen(openErr, fd) {
if (openErr) {
self.destroy();
self.emit('error', openErr);
return;
}
self.fd = fd;
self.emit('open', fd);
}
};
// Use our `end` method since it is patched for flush
WriteStream.prototype.destroySoon = WriteStream.prototype.end;
WriteStream.prototype._destroy = function(err, cb) {
this.close(function(err2) {
cb(err || err2);
});
};
WriteStream.prototype.close = function(cb) {
var that = this;
if (cb) {
this.once('close', cb);
}
if (this.closed || typeof this.fd !== 'number') {
if (typeof this.fd !== 'number') {
this.once('open', closeOnOpen);
return;
}
return process.nextTick(function() {
that.emit('close');
});
}
this.closed = true;
fs.close(this.fd, function(er) {
if (er) {
that.emit('error', er);
} else {
that.emit('close');
}
});
this.fd = null;
};
WriteStream.prototype._final = function(callback) {
if (typeof this.flush !== 'function') {
return callback();
}
this.flush(this.fd, callback);
};
function closeOnOpen() {
this.close();
}
WriteStream.prototype._write = function(data, encoding, callback) {
var self = this;
// This is from node core but I have no idea how to get code coverage on it
if (!Buffer.isBuffer(data)) {
return this.emit('error', new Error('Invalid data'));
}
if (typeof this.fd !== 'number') {
return this.once('open', onOpen);
}
fs.write(this.fd, data, 0, data.length, null, onWrite);
function onOpen() {
self._write(data, encoding, callback);
}
function onWrite(writeErr) {
if (writeErr) {
self.destroy();
callback(writeErr);
return;
}
callback();
}
};
module.exports = {
closeFd: closeFd,
isValidUnixId: isValidUnixId,
getFlags: getFlags,
isFatalOverwriteError: isFatalOverwriteError,
isFatalUnlinkError: isFatalUnlinkError,
getModeDiff: getModeDiff,
getTimesDiff: getTimesDiff,
getOwnerDiff: getOwnerDiff,
isOwner: isOwner,
reflectStat: reflectStat,
reflectLinkStat: reflectLinkStat,
updateMetadata: updateMetadata,
symlink: symlink,
writeFile: writeFile,
createWriteStream: createWriteStream,
};

View File

@@ -0,0 +1,38 @@
'use strict';
var gs = require('glob-stream');
var pumpify = require('pumpify');
var toThrough = require('to-through');
var isValidGlob = require('is-valid-glob');
var createResolver = require('resolve-options');
var config = require('./options');
var prepare = require('./prepare');
var wrapVinyl = require('./wrap-vinyl');
var sourcemap = require('./sourcemap');
var readContents = require('./read-contents');
var resolveSymlinks = require('./resolve-symlinks');
function src(glob, opt) {
var optResolver = createResolver(config, opt);
if (!isValidGlob(glob)) {
throw new Error('Invalid glob argument: ' + glob);
}
var streams = [
gs(glob, opt),
wrapVinyl(optResolver),
resolveSymlinks(optResolver),
prepare(optResolver),
readContents(optResolver),
sourcemap(optResolver),
];
var outputStream = pumpify.obj(streams);
return toThrough(outputStream);
}
module.exports = src;

View File

@@ -0,0 +1,29 @@
'use strict';
var config = {
buffer: {
type: 'boolean',
default: true,
},
read: {
type: 'boolean',
default: true,
},
since: {
type: 'date',
},
removeBOM: {
type: 'boolean',
default: true,
},
sourcemaps: {
type: 'boolean',
default: false,
},
resolveSymlinks: {
type: 'boolean',
default: true,
},
};
module.exports = config;

View File

@@ -0,0 +1,22 @@
'use strict';
var through = require('through2');
function prepareRead(optResolver) {
function normalize(file, enc, callback) {
var since = optResolver.resolve('since', file);
// Skip this file if since option is set and current file is too old
if (file.stat && file.stat.mtime <= since) {
return callback();
}
return callback(null, file);
}
return through.obj(normalize);
}
module.exports = prepareRead;

View File

@@ -0,0 +1,52 @@
'use strict';
var through = require('through2');
var readDir = require('./read-dir');
var readStream = require('./read-stream');
var readBuffer = require('./read-buffer');
var readSymbolicLink = require('./read-symbolic-link');
function readContents(optResolver) {
function readFile(file, enc, callback) {
// Skip reading contents if read option says so
var read = optResolver.resolve('read', file);
if (!read) {
return callback(null, file);
}
// Don't fail to read a directory
if (file.isDirectory()) {
return readDir(file, optResolver, onRead);
}
// Process symbolic links included with `resolveSymlinks` option
if (file.stat && file.stat.isSymbolicLink()) {
return readSymbolicLink(file, optResolver, onRead);
}
// Read and pass full contents
var buffer = optResolver.resolve('buffer', file);
if (buffer) {
return readBuffer(file, optResolver, onRead);
}
// Don't buffer anything - just pass streams
return readStream(file, optResolver, onRead);
// This is invoked by the various readXxx modules when they've finished
// reading the contents.
function onRead(readErr) {
if (readErr) {
return callback(readErr);
}
return callback(null, file);
}
}
return through.obj(readFile);
}
module.exports = readContents;

View File

@@ -0,0 +1,25 @@
'use strict';
var fs = require('graceful-fs');
var removeBomBuffer = require('remove-bom-buffer');
function bufferFile(file, optResolver, onRead) {
fs.readFile(file.path, onReadFile);
function onReadFile(readErr, data) {
if (readErr) {
return onRead(readErr);
}
var removeBOM = optResolver.resolve('removeBOM', file);
if (removeBOM) {
file.contents = removeBomBuffer(data);
} else {
file.contents = data;
}
onRead();
}
}
module.exports = bufferFile;

View File

@@ -0,0 +1,8 @@
'use strict';
function readDir(file, optResolver, onRead) {
// Do nothing for now
onRead();
}
module.exports = readDir;

View File

@@ -0,0 +1,31 @@
'use strict';
var fs = require('graceful-fs');
var removeBomStream = require('remove-bom-stream');
var lazystream = require('lazystream');
var createResolver = require('resolve-options');
function streamFile(file, optResolver, onRead) {
if (typeof optResolver === 'function') {
onRead = optResolver;
optResolver = createResolver();
}
var filePath = file.path;
var removeBOM = optResolver.resolve('removeBOM', file);
file.contents = new lazystream.Readable(function() {
var contents = fs.createReadStream(filePath);
if (removeBOM) {
return contents.pipe(removeBomStream());
}
return contents;
});
onRead();
}
module.exports = streamFile;

View File

@@ -0,0 +1,20 @@
'use strict';
var fs = require('graceful-fs');
function readLink(file, optResolver, onRead) {
fs.readlink(file.path, onReadlink);
function onReadlink(readErr, target) {
if (readErr) {
return onRead(readErr);
}
// Store the link target path
file.symlink = target;
onRead();
}
}
module.exports = readLink;

View File

@@ -0,0 +1,36 @@
'use strict';
var through = require('through2');
var fo = require('../file-operations');
function resolveSymlinks(optResolver) {
// A stat property is exposed on file objects as a (wanted) side effect
function resolveFile(file, enc, callback) {
fo.reflectLinkStat(file.path, file, onReflect);
function onReflect(statErr) {
if (statErr) {
return callback(statErr);
}
if (!file.stat.isSymbolicLink()) {
return callback(null, file);
}
var resolveSymlinks = optResolver.resolve('resolveSymlinks', file);
if (!resolveSymlinks) {
return callback(null, file);
}
// Get target's stats
fo.reflectStat(file.path, file, onReflect);
}
}
return through.obj(resolveFile);
}
module.exports = resolveSymlinks;

View File

@@ -0,0 +1,29 @@
'use strict';
var through = require('through2');
var sourcemap = require('vinyl-sourcemap');
function sourcemapStream(optResolver) {
function addSourcemap(file, enc, callback) {
var srcMap = optResolver.resolve('sourcemaps', file);
if (!srcMap) {
return callback(null, file);
}
sourcemap.add(file, onAdd);
function onAdd(sourcemapErr, updatedFile) {
if (sourcemapErr) {
return callback(sourcemapErr);
}
callback(null, updatedFile);
}
}
return through.obj(addSourcemap);
}
module.exports = sourcemapStream;

View File

@@ -0,0 +1,18 @@
'use strict';
var File = require('vinyl');
var through = require('through2');
function wrapVinyl() {
function wrapFile(globFile, enc, callback) {
var file = new File(globFile);
callback(null, file);
}
return through.obj(wrapFile);
}
module.exports = wrapVinyl;

View File

@@ -0,0 +1,43 @@
'use strict';
var pumpify = require('pumpify');
var lead = require('lead');
var mkdirpStream = require('fs-mkdirp-stream');
var createResolver = require('resolve-options');
var config = require('./options');
var prepare = require('./prepare');
var linkFile = require('./link-file');
var folderConfig = {
outFolder: {
type: 'string',
},
};
function symlink(outFolder, opt) {
if (!outFolder) {
throw new Error('Invalid symlink() folder argument.' +
' Please specify a non-empty string or a function.');
}
var optResolver = createResolver(config, opt);
var folderResolver = createResolver(folderConfig, { outFolder: outFolder });
function dirpath(file, callback) {
var dirMode = optResolver.resolve('dirMode', file);
callback(null, file.dirname, dirMode);
}
var stream = pumpify.obj(
prepare(folderResolver, optResolver),
mkdirpStream.obj(dirpath),
linkFile(optResolver)
);
// Sink the stream to start flowing
return lead(stream);
}
module.exports = symlink;

View File

@@ -0,0 +1,89 @@
'use strict';
var os = require('os');
var path = require('path');
var through = require('through2');
var fo = require('../file-operations');
var isWindows = (os.platform() === 'win32');
function linkStream(optResolver) {
function linkFile(file, enc, callback) {
var isRelative = optResolver.resolve('relativeSymlinks', file);
var flags = fo.getFlags({
overwrite: optResolver.resolve('overwrite', file),
append: false,
});
if (!isWindows) {
// On non-Windows, just use 'file'
return createLinkWithType('file');
}
fo.reflectStat(file.symlink, file, onReflectTarget);
function onReflectTarget(statErr) {
if (statErr && statErr.code !== 'ENOENT') {
return callback(statErr);
}
// If target doesn't exist, the vinyl will still carry the target stats.
// Let's use those to determine which kind of dangling link to create.
// This option provides a way to create a Junction instead of a
// Directory symlink on Windows. This comes with the following caveats:
// * NTFS Junctions cannot be relative.
// * NTFS Junctions MUST be directories.
// * NTFS Junctions must be on the same file system.
// * Most products CANNOT detect a directory is a Junction:
// This has the side effect of possibly having a whole directory
// deleted when a product is deleting the Junction directory.
// For example, JetBrains product lines will delete the entire contents
// of the TARGET directory because the product does not realize it's
// a symlink as the JVM and Node return false for isSymlink.
// This function is Windows only, so we don't need to check again
var useJunctions = optResolver.resolve('useJunctions', file);
var dirType = useJunctions ? 'junction' : 'dir';
var type = !statErr && file.isDirectory() ? dirType : 'file';
createLinkWithType(type);
}
function createLinkWithType(type) {
// This is done after prepare() to use the adjusted file.base property
if (isRelative && type !== 'junction') {
file.symlink = path.relative(file.base, file.symlink);
}
var opts = {
flags: flags,
type: type,
};
fo.symlink(file.symlink, file.path, opts, onSymlink);
}
function onSymlink(symlinkErr) {
if (symlinkErr) {
return callback(symlinkErr);
}
fo.reflectLinkStat(file.path, file, onReflectLink);
}
function onReflectLink(reflectErr) {
if (reflectErr) {
return callback(reflectErr);
}
callback(null, file);
}
}
return through.obj(linkFile);
}
module.exports = linkStream;

View File

@@ -0,0 +1,26 @@
'use strict';
var config = {
cwd: {
type: 'string',
default: process.cwd,
},
dirMode: {
type: 'number',
},
overwrite: {
type: 'boolean',
default: true,
},
relativeSymlinks: {
type: 'boolean',
default: false,
},
// This option is ignored on non-Windows platforms
useJunctions: {
type: 'boolean',
default: true,
},
};
module.exports = config;

View File

@@ -0,0 +1,51 @@
'use strict';
var path = require('path');
var fs = require('graceful-fs');
var Vinyl = require('vinyl');
var through = require('through2');
function prepareSymlink(folderResolver, optResolver) {
if (!folderResolver) {
throw new Error('Invalid output folder');
}
function normalize(file, enc, cb) {
if (!Vinyl.isVinyl(file)) {
return cb(new Error('Received a non-Vinyl object in `symlink()`'));
}
// TODO: Remove this after people upgrade vinyl/transition from gulp-util
if (typeof file.isSymbolic !== 'function') {
file = new Vinyl(file);
}
var cwd = path.resolve(optResolver.resolve('cwd', file));
var outFolderPath = folderResolver.resolve('outFolder', file);
if (!outFolderPath) {
return cb(new Error('Invalid output folder'));
}
var basePath = path.resolve(cwd, outFolderPath);
var writePath = path.resolve(basePath, file.relative);
// Wire up new properties
// Note: keep the target stats for now, we may need them in link-file
file.stat = (file.stat || new fs.Stats());
file.cwd = cwd;
file.base = basePath;
// This is the path we are linking *TO*
file.symlink = file.path;
file.path = writePath;
// We have to set contents to null for a link
// Otherwise `isSymbolic()` returns false
file.contents = null;
cb(null, file);
}
return through.obj(normalize);
}
module.exports = prepareSymlink;

View File

@@ -0,0 +1,110 @@
{
"_from": "vinyl-fs@^3.0.3",
"_id": "vinyl-fs@3.0.3",
"_inBundle": false,
"_integrity": "sha512-vIu34EkyNyJxmP0jscNzWBSygh7VWhqun6RmqVfXePrOwi9lhvRs//dOaGOTRUQr4tx7/zd26Tk5WeSVZitgng==",
"_location": "/gulp-vinyl-zip/vinyl-fs",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "vinyl-fs@^3.0.3",
"name": "vinyl-fs",
"escapedName": "vinyl-fs",
"rawSpec": "^3.0.3",
"saveSpec": null,
"fetchSpec": "^3.0.3"
},
"_requiredBy": [
"/gulp-vinyl-zip"
],
"_resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-3.0.3.tgz",
"_shasum": "c85849405f67428feabbbd5c5dbdd64f47d31bc7",
"_spec": "vinyl-fs@^3.0.3",
"_where": "/home/nathan/Projects/Upsilon/UpsilonVsCodeLanguageServer/Client/node_modules/gulp-vinyl-zip",
"author": {
"name": "Gulp Team",
"email": "team@gulpjs.com",
"url": "http://gulpjs.com/"
},
"bugs": {
"url": "https://github.com/gulpjs/vinyl-fs/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Eric Schoffstall",
"email": "yo@contra.io"
},
{
"name": "Blaine Bublitz",
"email": "blaine.bublitz@gmail.com"
}
],
"dependencies": {
"fs-mkdirp-stream": "^1.0.0",
"glob-stream": "^6.1.0",
"graceful-fs": "^4.0.0",
"is-valid-glob": "^1.0.0",
"lazystream": "^1.0.0",
"lead": "^1.0.0",
"object.assign": "^4.0.4",
"pumpify": "^1.3.5",
"readable-stream": "^2.3.3",
"remove-bom-buffer": "^3.0.0",
"remove-bom-stream": "^1.2.0",
"resolve-options": "^1.1.0",
"through2": "^2.0.0",
"to-through": "^2.0.0",
"value-or-function": "^3.0.0",
"vinyl": "^2.0.0",
"vinyl-sourcemap": "^1.1.0"
},
"deprecated": false,
"description": "Vinyl adapter for the file system.",
"devDependencies": {
"eslint": "^1.10.3",
"eslint-config-gulp": "^2.0.0",
"expect": "^1.19.0",
"istanbul": "^0.4.3",
"istanbul-coveralls": "^1.0.3",
"jscs": "^2.4.0",
"jscs-preset-gulp": "^1.0.0",
"mississippi": "^1.2.0",
"mocha": "^3.5.0",
"rimraf": "^2.6.1"
},
"engines": {
"node": ">= 0.10"
},
"files": [
"LICENSE",
"index.js",
"lib"
],
"homepage": "https://github.com/gulpjs/vinyl-fs#readme",
"keywords": [
"gulp",
"vinyl-adapter",
"vinyl",
"file",
"file system",
"fs",
"streams"
],
"license": "MIT",
"main": "index.js",
"name": "vinyl-fs",
"repository": {
"type": "git",
"url": "git+https://github.com/gulpjs/vinyl-fs.git"
},
"scripts": {
"cover": "istanbul cover _mocha --report lcovonly",
"coveralls": "npm run cover && istanbul-coveralls",
"lint": "eslint . && jscs index.js lib/ test/",
"pretest": "npm run lint",
"test": "mocha --async-only"
},
"version": "3.0.3"
}

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2013 Blaine Bublitz <blaine.bublitz@gmail.com>, Eric Schoffstall <yo@contra.io> and other contributors
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.

View File

@@ -0,0 +1,446 @@
<p align="center">
<a href="http://gulpjs.com">
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
</a>
</p>
# vinyl
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
Virtual file format.
## What is Vinyl?
Vinyl is a very simple metadata object that describes a file. When you think of a file, two attributes come to mind: `path` and `contents`. These are the main attributes on a Vinyl object. A file does not necessarily represent something on your computers file system. You have files on S3, FTP, Dropbox, Box, CloudThingly.io and other services. Vinyl can be used to describe files from all of these sources.
## What is a Vinyl Adapter?
While Vinyl provides a clean way to describe a file, we also need a way to access these files. Each file source needs what I call a "Vinyl adapter". A Vinyl adapter simply exposes a `src(globs)` and a `dest(folder)` method. Each return a stream. The `src` stream produces Vinyl objects, and the `dest` stream consumes Vinyl objects. Vinyl adapters can expose extra methods that might be specific to their input/output medium, such as the `symlink` method [`vinyl-fs`][vinyl-fs] provides.
## Usage
```js
var Vinyl = require('vinyl');
var jsFile = new Vinyl({
cwd: '/',
base: '/test/',
path: '/test/file.js',
contents: new Buffer('var x = 123')
});
```
## API
### `new Vinyl([options])`
The constructor is used to create a new instance of `Vinyl`. Each instance represents a separate file, directory or symlink.
All internally managed paths (`cwd`, `base`, `path`, `history`) are normalized and have trailing separators removed. See [Normalization and concatenation][normalization] for more information.
Options may be passed upon instantiation to create a file with specific properties.
#### `options`
Options are not mutated by the constructor.
##### `options.cwd`
The current working directory of the file.
Type: `String`
Default: `process.cwd()`
##### `options.base`
Used for calculating the `relative` property. This is typically where a glob starts.
Type: `String`
Default: `options.cwd`
##### `options.path`
The full path to the file.
Type: `String`
Default: `undefined`
##### `options.history`
Stores the path history. If `options.path` and `options.history` are both passed, `options.path` is appended to `options.history`. All `options.history` paths are normalized by the `file.path` setter.
Type: `Array`
Default: `[]` (or `[options.path]` if `options.path` is passed)
##### `options.stat`
The result of an `fs.stat` call. This is how you mark the file as a directory or symbolic link. See [isDirectory()][is-directory], [isSymbolic()][is-symbolic] and [fs.Stats][fs-stats] for more information.
Type: [`fs.Stats`][fs-stats]
Default: `undefined`
##### `options.contents`
The contents of the file. If `options.contents` is a [`ReadableStream`][readable-stream], it is wrapped in a [`cloneable-readable`][cloneable-readable] stream.
Type: [`ReadableStream`][readable-stream], [`Buffer`][buffer], or `null`
Default: `null`
##### `options.{custom}`
Any other option properties will be directly assigned to the new Vinyl object.
```js
var Vinyl = require('vinyl');
var file = new Vinyl({ foo: 'bar' });
file.foo === 'bar'; // true
```
### Instance methods
Each Vinyl object will have instance methods. Every method will be available but may return differently based on what properties were set upon instantiation or modified since.
#### `file.isBuffer()`
Returns `true` if the file contents are a [`Buffer`][buffer], otherwise `false`.
#### `file.isStream()`
Returns `true` if the file contents are a [`Stream`][stream], otherwise `false`.
#### `file.isNull()`
Returns `true` if the file contents are `null`, otherwise `false`.
#### `file.isDirectory()`
Returns `true` if the file represents a directory, otherwise `false`.
A file is considered a directory when:
- `file.isNull()` is `true`
- `file.stat` is an object
- `file.stat.isDirectory()` returns `true`
When constructing a Vinyl object, pass in a valid [`fs.Stats`][fs-stats] object via `options.stat`. If you are mocking the [`fs.Stats`][fs-stats] object, you may need to stub the `isDirectory()` method.
#### `file.isSymbolic()`
Returns `true` if the file represents a symbolic link, otherwise `false`.
A file is considered symbolic when:
- `file.isNull()` is `true`
- `file.stat` is an object
- `file.stat.isSymbolicLink()` returns `true`
When constructing a Vinyl object, pass in a valid [`fs.Stats`][fs-stats] object via `options.stat`. If you are mocking the [`fs.Stats`][fs-stats] object, you may need to stub the `isSymbolicLink()` method.
#### `file.clone([options])`
Returns a new Vinyl object with all attributes cloned.
__By default custom attributes are cloned deeply.__
If `options` or `options.deep` is `false`, custom attributes will not be cloned deeply.
If `file.contents` is a [`Buffer`][buffer] and `options.contents` is `false`, the [`Buffer`][buffer] reference will be reused instead of copied.
#### `file.inspect()`
Returns a formatted-string interpretation of the Vinyl object. Automatically called by node's `console.log`.
### Instance properties
Each Vinyl object will have instance properties. Some may be unavailable based on what properties were set upon instantiation or modified since.
#### `file.contents`
Gets and sets the contents of the file. If set to a [`ReadableStream`][readable-stream], it is wrapped in a [`cloneable-readable`][cloneable-readable] stream.
Throws when set to any value other than a [`ReadableStream`][readable-stream], a [`Buffer`][buffer] or `null`.
Type: [`ReadableStream`][readable-stream], [`Buffer`][buffer], or `null`
#### `file.cwd`
Gets and sets current working directory. Will always be normalized and have trailing separators removed.
Throws when set to any value other than non-empty strings.
Type: `String`
#### `file.base`
Gets and sets base directory. Used for relative pathing (typically where a glob starts).
When `null` or `undefined`, it simply proxies the `file.cwd` property. Will always be normalized and have trailing separators removed.
Throws when set to any value other than non-empty strings or `null`/`undefined`.
Type: `String`
#### `file.path`
Gets and sets the absolute pathname string or `undefined`. Setting to a different value appends the new path to `file.history`. If set to the same value as the current path, it is ignored. All new values are normalized and have trailing separators removed.
Throws when set to any value other than a string.
Type: `String`
#### `file.history`
Array of `file.path` values the Vinyl object has had, from `file.history[0]` (original) through `file.history[file.history.length - 1]` (current). `file.history` and its elements should normally be treated as read-only and only altered indirectly by setting `file.path`.
Type: `Array`
#### `file.relative`
Gets the result of `path.relative(file.base, file.path)`.
Throws when set or when `file.path` is not set.
Type: `String`
Example:
```js
var file = new File({
cwd: '/',
base: '/test/',
path: '/test/file.js'
});
console.log(file.relative); // file.js
```
#### `file.dirname`
Gets and sets the dirname of `file.path`. Will always be normalized and have trailing separators removed.
Throws when `file.path` is not set.
Type: `String`
Example:
```js
var file = new File({
cwd: '/',
base: '/test/',
path: '/test/file.js'
});
console.log(file.dirname); // /test
file.dirname = '/specs';
console.log(file.dirname); // /specs
console.log(file.path); // /specs/file.js
```
#### `file.basename`
Gets and sets the basename of `file.path`.
Throws when `file.path` is not set.
Type: `String`
Example:
```js
var file = new File({
cwd: '/',
base: '/test/',
path: '/test/file.js'
});
console.log(file.basename); // file.js
file.basename = 'file.txt';
console.log(file.basename); // file.txt
console.log(file.path); // /test/file.txt
```
#### `file.stem`
Gets and sets stem (filename without suffix) of `file.path`.
Throws when `file.path` is not set.
Type: `String`
Example:
```js
var file = new File({
cwd: '/',
base: '/test/',
path: '/test/file.js'
});
console.log(file.stem); // file
file.stem = 'foo';
console.log(file.stem); // foo
console.log(file.path); // /test/foo.js
```
#### `file.extname`
Gets and sets extname of `file.path`.
Throws when `file.path` is not set.
Type: `String`
Example:
```js
var file = new File({
cwd: '/',
base: '/test/',
path: '/test/file.js'
});
console.log(file.extname); // .js
file.extname = '.txt';
console.log(file.extname); // .txt
console.log(file.path); // /test/file.txt
```
#### `file.symlink`
Gets and sets the path where the file points to if it's a symbolic link. Will always be normalized and have trailing separators removed.
Throws when set to any value other than a string.
Type: `String`
### `Vinyl.isVinyl(file)`
Static method used for checking if an object is a Vinyl file. Use this method instead of `instanceof`.
Takes an object and returns `true` if it is a Vinyl file, otherwise returns `false`.
__Note: This method uses an internal flag that some older versions of Vinyl didn't expose.__
Example:
```js
var Vinyl = require('vinyl');
var file = new Vinyl();
var notAFile = {};
Vinyl.isVinyl(file); // true
Vinyl.isVinyl(notAFile); // false
```
### `Vinyl.isCustomProp(property)`
Static method used by Vinyl when setting values inside the constructor or when copying properties in `file.clone()`.
Takes a string `property` and returns `true` if the property is not used internally, otherwise returns `false`.
This method is useful for inheritting from the Vinyl constructor. Read more in [Extending Vinyl][extending-vinyl].
Example:
```js
var Vinyl = require('vinyl');
Vinyl.isCustomProp('sourceMap'); // true
Vinyl.isCustomProp('path'); // false -> internal getter/setter
```
## Normalization and concatenation
Since all properties are normalized in their setters, you can just concatenate with `/`, and normalization takes care of it properly on all platforms.
Example:
```js
var file = new File();
file.path = '/' + 'test' + '/' + 'foo.bar';
console.log(file.path);
// posix => /test/foo.bar
// win32 => \\test\\foo.bar
```
But never concatenate with `\`, since that is a valid filename character on posix system.
## Extending Vinyl
When extending Vinyl into your own class with extra features, you need to think about a few things.
When you have your own properties that are managed internally, you need to extend the static `isCustomProp` method to return `false` when one of these properties is queried.
```js
var Vinyl = require('vinyl');
var builtInProps = ['foo', '_foo'];
class SuperFile extends Vinyl {
constructor(options) {
super(options);
this._foo = 'example internal read-only value';
}
get foo() {
return this._foo;
}
static isCustomProp(name) {
return super.isCustomProp(name) && builtInProps.indexOf(name) === -1;
}
}
```
This makes properties `foo` and `_foo` ignored when cloning, and when passed in options to `constructor(options)` so they don't get assigned to the new object.
Same goes for `clone()`. If you have your own internal stuff that needs special handling during cloning, you should extend it to do so.
## License
MIT
[is-symbolic]: #issymbolic
[is-directory]: #isdirectory
[normalization]: #normalization-and-concatenation
[extending-vinyl]: #extending-vinyl
[stream]: https://nodejs.org/api/stream.html#stream_stream
[readable-stream]: https://nodejs.org/api/stream.html#stream_readable_streams
[buffer]: https://nodejs.org/api/buffer.html#buffer_class_buffer
[fs-stats]: http://nodejs.org/api/fs.html#fs_class_fs_stats
[vinyl-fs]: https://github.com/gulpjs/vinyl-fs
[cloneable-readable]: https://github.com/mcollina/cloneable-readable
[downloads-image]: http://img.shields.io/npm/dm/vinyl.svg
[npm-url]: https://www.npmjs.com/package/vinyl
[npm-image]: http://img.shields.io/npm/v/vinyl.svg
[travis-url]: https://travis-ci.org/gulpjs/vinyl
[travis-image]: http://img.shields.io/travis/gulpjs/vinyl.svg?label=travis-ci
[appveyor-url]: https://ci.appveyor.com/project/gulpjs/vinyl
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/vinyl.svg?label=appveyor
[coveralls-url]: https://coveralls.io/r/gulpjs/vinyl
[coveralls-image]: http://img.shields.io/coveralls/gulpjs/vinyl/master.svg
[gitter-url]: https://gitter.im/gulpjs/gulp
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg

View File

@@ -0,0 +1,334 @@
'use strict';
var path = require('path');
var util = require('util');
var isBuffer = require('buffer').Buffer.isBuffer;
var clone = require('clone');
var cloneable = require('cloneable-readable');
var replaceExt = require('replace-ext');
var cloneStats = require('clone-stats');
var cloneBuffer = require('clone-buffer');
var removeTrailingSep = require('remove-trailing-separator');
var isStream = require('./lib/is-stream');
var normalize = require('./lib/normalize');
var inspectStream = require('./lib/inspect-stream');
var builtInFields = [
'_contents', '_symlink', 'contents', 'stat', 'history', 'path',
'_base', 'base', '_cwd', 'cwd',
];
function File(file) {
var self = this;
if (!file) {
file = {};
}
// Stat = files stats object
this.stat = file.stat || null;
// Contents = stream, buffer, or null if not read
this.contents = file.contents || null;
// Replay path history to ensure proper normalization and trailing sep
var history = Array.prototype.slice.call(file.history || []);
if (file.path) {
history.push(file.path);
}
this.history = [];
history.forEach(function(path) {
self.path = path;
});
this.cwd = file.cwd || process.cwd();
this.base = file.base;
this._isVinyl = true;
this._symlink = null;
// Set custom properties
Object.keys(file).forEach(function(key) {
if (self.constructor.isCustomProp(key)) {
self[key] = file[key];
}
});
}
File.prototype.isBuffer = function() {
return isBuffer(this.contents);
};
File.prototype.isStream = function() {
return isStream(this.contents);
};
File.prototype.isNull = function() {
return (this.contents === null);
};
File.prototype.isDirectory = function() {
if (!this.isNull()) {
return false;
}
if (this.stat && typeof this.stat.isDirectory === 'function') {
return this.stat.isDirectory();
}
return false;
};
File.prototype.isSymbolic = function() {
if (!this.isNull()) {
return false;
}
if (this.stat && typeof this.stat.isSymbolicLink === 'function') {
return this.stat.isSymbolicLink();
}
return false;
};
File.prototype.clone = function(opt) {
var self = this;
if (typeof opt === 'boolean') {
opt = {
deep: opt,
contents: true,
};
} else if (!opt) {
opt = {
deep: true,
contents: true,
};
} else {
opt.deep = opt.deep === true;
opt.contents = opt.contents !== false;
}
// Clone our file contents
var contents;
if (this.isStream()) {
contents = this.contents.clone();
} else if (this.isBuffer()) {
contents = opt.contents ? cloneBuffer(this.contents) : this.contents;
}
var file = new this.constructor({
cwd: this.cwd,
base: this.base,
stat: (this.stat ? cloneStats(this.stat) : null),
history: this.history.slice(),
contents: contents,
});
// Clone our custom properties
Object.keys(this).forEach(function(key) {
if (self.constructor.isCustomProp(key)) {
file[key] = opt.deep ? clone(self[key], true) : self[key];
}
});
return file;
};
File.prototype.inspect = function() {
var inspect = [];
// Use relative path if possible
var filePath = this.path ? this.relative : null;
if (filePath) {
inspect.push('"' + filePath + '"');
}
if (this.isBuffer()) {
inspect.push(this.contents.inspect());
}
if (this.isStream()) {
inspect.push(inspectStream(this.contents));
}
return '<File ' + inspect.join(' ') + '>';
};
// Newer Node.js versions use this symbol for custom inspection.
if (util.inspect.custom) {
File.prototype[util.inspect.custom] = File.prototype.inspect;
}
File.isCustomProp = function(key) {
return builtInFields.indexOf(key) === -1;
};
File.isVinyl = function(file) {
return (file && file._isVinyl === true) || false;
};
// Virtual attributes
// Or stuff with extra logic
Object.defineProperty(File.prototype, 'contents', {
get: function() {
return this._contents;
},
set: function(val) {
if (!isBuffer(val) && !isStream(val) && (val !== null)) {
throw new Error('File.contents can only be a Buffer, a Stream, or null.');
}
// Ask cloneable if the stream is a already a cloneable
// this avoid piping into many streams
// reducing the overhead of cloning
if (isStream(val) && !cloneable.isCloneable(val)) {
val = cloneable(val);
}
this._contents = val;
},
});
Object.defineProperty(File.prototype, 'cwd', {
get: function() {
return this._cwd;
},
set: function(cwd) {
if (!cwd || typeof cwd !== 'string') {
throw new Error('cwd must be a non-empty string.');
}
this._cwd = removeTrailingSep(normalize(cwd));
},
});
Object.defineProperty(File.prototype, 'base', {
get: function() {
return this._base || this._cwd;
},
set: function(base) {
if (base == null) {
delete this._base;
return;
}
if (typeof base !== 'string' || !base) {
throw new Error('base must be a non-empty string, or null/undefined.');
}
base = removeTrailingSep(normalize(base));
if (base !== this._cwd) {
this._base = base;
} else {
delete this._base;
}
},
});
// TODO: Should this be moved to vinyl-fs?
Object.defineProperty(File.prototype, 'relative', {
get: function() {
if (!this.path) {
throw new Error('No path specified! Can not get relative.');
}
return path.relative(this.base, this.path);
},
set: function() {
throw new Error('File.relative is generated from the base and path attributes. Do not modify it.');
},
});
Object.defineProperty(File.prototype, 'dirname', {
get: function() {
if (!this.path) {
throw new Error('No path specified! Can not get dirname.');
}
return path.dirname(this.path);
},
set: function(dirname) {
if (!this.path) {
throw new Error('No path specified! Can not set dirname.');
}
this.path = path.join(dirname, this.basename);
},
});
Object.defineProperty(File.prototype, 'basename', {
get: function() {
if (!this.path) {
throw new Error('No path specified! Can not get basename.');
}
return path.basename(this.path);
},
set: function(basename) {
if (!this.path) {
throw new Error('No path specified! Can not set basename.');
}
this.path = path.join(this.dirname, basename);
},
});
// Property for getting/setting stem of the filename.
Object.defineProperty(File.prototype, 'stem', {
get: function() {
if (!this.path) {
throw new Error('No path specified! Can not get stem.');
}
return path.basename(this.path, this.extname);
},
set: function(stem) {
if (!this.path) {
throw new Error('No path specified! Can not set stem.');
}
this.path = path.join(this.dirname, stem + this.extname);
},
});
Object.defineProperty(File.prototype, 'extname', {
get: function() {
if (!this.path) {
throw new Error('No path specified! Can not get extname.');
}
return path.extname(this.path);
},
set: function(extname) {
if (!this.path) {
throw new Error('No path specified! Can not set extname.');
}
this.path = replaceExt(this.path, extname);
},
});
Object.defineProperty(File.prototype, 'path', {
get: function() {
return this.history[this.history.length - 1];
},
set: function(path) {
if (typeof path !== 'string') {
throw new Error('path should be a string.');
}
path = removeTrailingSep(normalize(path));
// Record history only when path changed
if (path && path !== this.path) {
this.history.push(path);
}
},
});
Object.defineProperty(File.prototype, 'symlink', {
get: function() {
return this._symlink;
},
set: function(symlink) {
// TODO: should this set the mode to symbolic if set?
if (typeof symlink !== 'string') {
throw new Error('symlink should be a string');
}
this._symlink = removeTrailingSep(normalize(symlink));
},
});
module.exports = File;

View File

@@ -0,0 +1,13 @@
'use strict';
function inspectStream(stream) {
var streamType = stream.constructor.name;
// Avoid StreamStream
if (streamType === 'Stream') {
streamType = '';
}
return '<' + streamType + 'Stream>';
}
module.exports = inspectStream;

View File

@@ -0,0 +1,15 @@
'use strict';
function isStream(stream) {
if (!stream) {
return false;
}
if (typeof stream.pipe !== 'function') {
return false;
}
return true;
}
module.exports = isStream;

View File

@@ -0,0 +1,9 @@
'use strict';
var path = require('path');
function normalize(str) {
return str === '' ? str : path.normalize(str);
}
module.exports = normalize;

View File

@@ -0,0 +1,98 @@
{
"_from": "vinyl@^2.0.2",
"_id": "vinyl@2.2.0",
"_inBundle": false,
"_integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==",
"_location": "/gulp-vinyl-zip/vinyl",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "vinyl@^2.0.2",
"name": "vinyl",
"escapedName": "vinyl",
"rawSpec": "^2.0.2",
"saveSpec": null,
"fetchSpec": "^2.0.2"
},
"_requiredBy": [
"/gulp-vinyl-zip",
"/gulp-vinyl-zip/vinyl-fs"
],
"_resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",
"_shasum": "d85b07da96e458d25b2ffe19fece9f2caa13ed86",
"_spec": "vinyl@^2.0.2",
"_where": "/home/nathan/Projects/Upsilon/UpsilonVsCodeLanguageServer/Client/node_modules/gulp-vinyl-zip",
"author": {
"name": "Gulp Team",
"email": "team@gulpjs.com",
"url": "http://gulpjs.com/"
},
"bugs": {
"url": "https://github.com/gulpjs/vinyl/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Eric Schoffstall",
"email": "yo@contra.io"
},
{
"name": "Blaine Bublitz",
"email": "blaine.bublitz@gmail.com"
}
],
"dependencies": {
"clone": "^2.1.1",
"clone-buffer": "^1.0.0",
"clone-stats": "^1.0.0",
"cloneable-readable": "^1.0.0",
"remove-trailing-separator": "^1.0.1",
"replace-ext": "^1.0.0"
},
"deprecated": false,
"description": "Virtual file format.",
"devDependencies": {
"eslint": "^1.7.3",
"eslint-config-gulp": "^2.0.0",
"expect": "^1.20.2",
"istanbul": "^0.4.3",
"istanbul-coveralls": "^1.0.3",
"jscs": "^2.3.5",
"jscs-preset-gulp": "^1.0.0",
"mississippi": "^1.2.0",
"mocha": "^2.4.5"
},
"engines": {
"node": ">= 0.10"
},
"files": [
"LICENSE",
"index.js",
"lib"
],
"homepage": "https://github.com/gulpjs/vinyl#readme",
"keywords": [
"virtual",
"filesystem",
"file",
"directory",
"stat",
"path"
],
"license": "MIT",
"main": "index.js",
"name": "vinyl",
"repository": {
"type": "git",
"url": "git+https://github.com/gulpjs/vinyl.git"
},
"scripts": {
"cover": "istanbul cover _mocha --report lcovonly",
"coveralls": "npm run cover && istanbul-coveralls",
"lint": "eslint . && jscs index.js lib/ test/",
"pretest": "npm run lint",
"test": "mocha --async-only"
},
"version": "2.2.0"
}

95
Client/node_modules/gulp-vinyl-zip/package.json generated vendored Executable file
View File

@@ -0,0 +1,95 @@
{
"_from": "gulp-vinyl-zip@^2.1.0",
"_id": "gulp-vinyl-zip@2.1.1",
"_inBundle": false,
"_integrity": "sha512-OPnsZkMwiU8UbH5BMlYRb/SccOAZUnwUW7mQvqYadap8MMdgN7ae0ua1rMEE2s9EyqqijN1Sdvoz29/MbPaq9Q==",
"_location": "/gulp-vinyl-zip",
"_phantomChildren": {
"clone-buffer": "1.0.0",
"cloneable-readable": "1.1.2",
"extend": "3.0.2",
"fs-mkdirp-stream": "1.0.0",
"glob": "7.1.3",
"glob-parent": "3.1.0",
"graceful-fs": "4.1.15",
"inherits": "2.0.3",
"is-absolute": "1.0.0",
"is-negated-glob": "1.0.0",
"lazystream": "1.0.0",
"lead": "1.0.0",
"object.assign": "4.1.0",
"pumpify": "1.5.1",
"readable-stream": "2.3.6",
"remove-bom-buffer": "3.0.0",
"remove-bom-stream": "1.2.0",
"remove-trailing-separator": "1.1.0",
"replace-ext": "1.0.0",
"resolve-options": "1.1.0",
"through2": "2.0.5",
"to-through": "2.0.0",
"unique-stream": "2.2.1",
"value-or-function": "3.0.0",
"vinyl-sourcemap": "1.1.0"
},
"_requested": {
"type": "range",
"registry": true,
"raw": "gulp-vinyl-zip@^2.1.0",
"name": "gulp-vinyl-zip",
"escapedName": "gulp-vinyl-zip",
"rawSpec": "^2.1.0",
"saveSpec": null,
"fetchSpec": "^2.1.0"
},
"_requiredBy": [
"/vscode"
],
"_resolved": "https://registry.npmjs.org/gulp-vinyl-zip/-/gulp-vinyl-zip-2.1.1.tgz",
"_shasum": "211aebdc5e4f702ddaf17b4e8b1ef6e3612a8b04",
"_spec": "gulp-vinyl-zip@^2.1.0",
"_where": "/home/nathan/Projects/Upsilon/UpsilonVsCodeLanguageServer/Client/node_modules/vscode",
"author": {
"name": "João Moreno"
},
"bugs": {
"url": "https://github.com/joaomoreno/gulp-vinyl-zip/issues"
},
"bundleDependencies": false,
"dependencies": {
"event-stream": "^3.3.1",
"queue": "^4.2.1",
"through2": "^2.0.3",
"vinyl": "^2.0.2",
"vinyl-fs": "^3.0.3",
"yauzl": "^2.2.1",
"yazl": "^2.2.1"
},
"deprecated": false,
"description": "Streaming vinyl adapter for zip archives",
"devDependencies": {
"mocha": "^3.0.2",
"temp": "^0.8.1"
},
"homepage": "https://github.com/joaomoreno/gulp-vinyl-zip",
"keywords": [
"gulp",
"gulpplugin",
"yazl",
"yazul",
"zip",
"streams",
"vinyl",
"vinyl-zip"
],
"license": "MIT",
"main": "index.js",
"name": "gulp-vinyl-zip",
"repository": {
"type": "git",
"url": "git+https://github.com/joaomoreno/gulp-vinyl-zip.git"
},
"scripts": {
"test": "mocha"
},
"version": "2.1.1"
}

BIN
Client/node_modules/gulp-vinyl-zip/test/assets/archive.zip generated vendored Executable file

Binary file not shown.

134
Client/node_modules/gulp-vinyl-zip/test/tests.js generated vendored Executable file
View File

@@ -0,0 +1,134 @@
'use strict';
/*global describe,it*/
var assert = require('assert');
var fs = require('fs');
var path = require('path');
var through = require('through2');
var temp = require('temp').track();
var vfs = require('vinyl-fs');
var lib = require('..');
describe('gulp-vinyl-zip', function () {
it('src should be able to read from archives', function (cb) {
var count = 0;
lib.src(path.join(__dirname, 'assets', 'archive.zip'))
.pipe(through.obj(function(chunk, enc, cb) {
count++;
cb();
}, function () {
assert.equal(7, count);
cb();
}));
});
it('src should be able to read from archives in streams', function (cb) {
var count = 0;
vfs.src(path.join(__dirname, 'assets', '*.zip'))
.pipe(lib.src())
.pipe(through.obj(function(chunk, enc, cb) {
count++;
cb();
}, function () {
assert.equal(7, count);
cb();
}));
});
it('dest should be able to create an archive from another archive', function (cb) {
var dest = temp.openSync('gulp-vinyl-zip-test').path;
lib.src(path.join(__dirname, 'assets', 'archive.zip'))
.pipe(lib.dest(dest))
.on('end', function () {
assert(fs.existsSync(dest));
cb();
});
});
it('dest should be able to create an archive\'s directory tree', function (cb) {
var dest = temp.mkdirSync('gulp-vinyl-zip-test');
var archive = path.join(dest, 'foo', 'bar', 'archive.zip');
lib.src(path.join(__dirname, 'assets', 'archive.zip'))
.pipe(lib.dest(archive))
.on('end', function () {
assert(fs.existsSync(archive));
cb();
});
});
it('should be compatible with vinyl-fs', function (cb) {
var dest = temp.mkdirSync('gulp-vinyl-zip-test');
lib.src(path.join(__dirname, 'assets', 'archive.zip'))
.pipe(vfs.dest(dest))
.on('end', function () {
assert(fs.existsSync(dest));
assert.equal(4, fs.readdirSync(dest).length);
cb();
});
});
it('dest should preserve stat', function (cb) {
var dest = temp.openSync('gulp-vinyl-zip-test').path;
var stats = Object.create(null);
lib.src(path.join(__dirname, 'assets', 'archive.zip'))
.pipe(through.obj(function (file, enc, cb) {
assert(file.stat);
stats[file.path] = file.stat;
cb(null, file);
}, function (cb) {
this.emit('end');
cb();
}))
.pipe(lib.dest(dest))
.on('end', function () {
var count = 0;
lib.src(dest)
.pipe(through.obj(function (file, enc, cb) {
count++;
if (stats[file.path].atime.valueOf() || file.stat.atime.valueOf()) {
assert.equal(stats[file.path].atime.getTime(), file.stat.atime.getTime());
}
if (stats[file.path].ctime.valueOf() || file.stat.ctime.valueOf()) {
assert.equal(stats[file.path].ctime.getTime(), file.stat.ctime.getTime());
}
if (stats[file.path].mtime.valueOf() || file.stat.mtime.valueOf()) {
assert.equal(stats[file.path].mtime.getTime(), file.stat.mtime.getTime());
}
assert.equal(stats[file.path].isFile(), file.stat.isFile());
assert.equal(stats[file.path].isDirectory(), file.stat.isDirectory());
assert.equal(stats[file.path].isSymbolicLink(), file.stat.isSymbolicLink());
cb();
}, function () {
assert.equal(7, count);
cb();
}));
});
});
it('dest should not assume files have `stat`', function (cb) {
var dest = temp.openSync('gulp-vinyl-zip-test').path;
lib.src(path.join(__dirname, 'assets', 'archive.zip'))
.pipe(through.obj(function(chunk, enc, cb) {
delete chunk.stat;
this.push(chunk);
cb();
}))
.pipe(lib.dest(dest))
.on('end', cb);
});
});