aboutsummaryrefslogtreecommitdiff
path: root/node_modules/archiver-utils
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/archiver-utils')
-rw-r--r--node_modules/archiver-utils/LICENSE22
-rw-r--r--node_modules/archiver-utils/README.md7
-rw-r--r--node_modules/archiver-utils/file.js206
-rw-r--r--node_modules/archiver-utils/index.js156
-rw-r--r--node_modules/archiver-utils/package.json51
5 files changed, 442 insertions, 0 deletions
diff --git a/node_modules/archiver-utils/LICENSE b/node_modules/archiver-utils/LICENSE
new file mode 100644
index 000000000..af5a4f6c1
--- /dev/null
+++ b/node_modules/archiver-utils/LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2015 Chris Talkington.
+
+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. \ No newline at end of file
diff --git a/node_modules/archiver-utils/README.md b/node_modules/archiver-utils/README.md
new file mode 100644
index 000000000..4f654c3b0
--- /dev/null
+++ b/node_modules/archiver-utils/README.md
@@ -0,0 +1,7 @@
+# archiver-utils v1.2.0 [![Build Status](https://travis-ci.org/archiverjs/archiver-utils.svg?branch=master)](https://travis-ci.org/archiverjs/archiver-utils) [![Build status](https://ci.appveyor.com/api/projects/status/7254ojgmlglhqbed/branch/master?svg=true)](https://ci.appveyor.com/project/ctalkington/archiver-utils/branch/master)
+
+
+## Things of Interest
+- [Changelog](https://github.com/archiverjs/archiver-utils/releases)
+- [Contributing](https://github.com/archiverjs/archiver-utils/blob/master/CONTRIBUTING.md)
+- [MIT License](https://github.com/archiverjs/archiver-utils/blob/master/LICENSE) \ No newline at end of file
diff --git a/node_modules/archiver-utils/file.js b/node_modules/archiver-utils/file.js
new file mode 100644
index 000000000..6218f687b
--- /dev/null
+++ b/node_modules/archiver-utils/file.js
@@ -0,0 +1,206 @@
+/**
+ * archiver-utils
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
+ */
+var fs = require('graceful-fs');
+var path = require('path');
+
+var _ = require('lodash');
+var glob = require('glob');
+
+var file = module.exports = {};
+
+var pathSeparatorRe = /[\/\\]/g;
+
+// Process specified wildcard glob patterns or filenames against a
+// callback, excluding and uniquing files in the result set.
+var processPatterns = function(patterns, fn) {
+ // Filepaths to return.
+ var result = [];
+ // Iterate over flattened patterns array.
+ _.flatten(patterns).forEach(function(pattern) {
+ // If the first character is ! it should be omitted
+ var exclusion = pattern.indexOf('!') === 0;
+ // If the pattern is an exclusion, remove the !
+ if (exclusion) { pattern = pattern.slice(1); }
+ // Find all matching files for this pattern.
+ var matches = fn(pattern);
+ if (exclusion) {
+ // If an exclusion, remove matching files.
+ result = _.difference(result, matches);
+ } else {
+ // Otherwise add matching files.
+ result = _.union(result, matches);
+ }
+ });
+ return result;
+};
+
+// True if the file path exists.
+file.exists = function() {
+ var filepath = path.join.apply(path, arguments);
+ return fs.existsSync(filepath);
+};
+
+// Return an array of all file paths that match the given wildcard patterns.
+file.expand = function() {
+ var args = _.toArray(arguments);
+ // If the first argument is an options object, save those options to pass
+ // into the File.prototype.glob.sync method.
+ var options = _.isPlainObject(args[0]) ? args.shift() : {};
+ // Use the first argument if it's an Array, otherwise convert the arguments
+ // object to an array and use that.
+ var patterns = Array.isArray(args[0]) ? args[0] : args;
+ // Return empty set if there are no patterns or filepaths.
+ if (patterns.length === 0) { return []; }
+ // Return all matching filepaths.
+ var matches = processPatterns(patterns, function(pattern) {
+ // Find all matching files for this pattern.
+ return glob.sync(pattern, options);
+ });
+ // Filter result set?
+ if (options.filter) {
+ matches = matches.filter(function(filepath) {
+ filepath = path.join(options.cwd || '', filepath);
+ try {
+ if (typeof options.filter === 'function') {
+ return options.filter(filepath);
+ } else {
+ // If the file is of the right type and exists, this should work.
+ return fs.statSync(filepath)[options.filter]();
+ }
+ } catch(e) {
+ // Otherwise, it's probably not the right type.
+ return false;
+ }
+ });
+ }
+ return matches;
+};
+
+// Build a multi task "files" object dynamically.
+file.expandMapping = function(patterns, destBase, options) {
+ options = _.defaults({}, options, {
+ rename: function(destBase, destPath) {
+ return path.join(destBase || '', destPath);
+ }
+ });
+ var files = [];
+ var fileByDest = {};
+ // Find all files matching pattern, using passed-in options.
+ file.expand(options, patterns).forEach(function(src) {
+ var destPath = src;
+ // Flatten?
+ if (options.flatten) {
+ destPath = path.basename(destPath);
+ }
+ // Change the extension?
+ if (options.ext) {
+ destPath = destPath.replace(/(\.[^\/]*)?$/, options.ext);
+ }
+ // Generate destination filename.
+ var dest = options.rename(destBase, destPath, options);
+ // Prepend cwd to src path if necessary.
+ if (options.cwd) { src = path.join(options.cwd, src); }
+ // Normalize filepaths to be unix-style.
+ dest = dest.replace(pathSeparatorRe, '/');
+ src = src.replace(pathSeparatorRe, '/');
+ // Map correct src path to dest path.
+ if (fileByDest[dest]) {
+ // If dest already exists, push this src onto that dest's src array.
+ fileByDest[dest].src.push(src);
+ } else {
+ // Otherwise create a new src-dest file mapping object.
+ files.push({
+ src: [src],
+ dest: dest,
+ });
+ // And store a reference for later use.
+ fileByDest[dest] = files[files.length - 1];
+ }
+ });
+ return files;
+};
+
+// reusing bits of grunt's multi-task source normalization
+file.normalizeFilesArray = function(data) {
+ var files = [];
+
+ data.forEach(function(obj) {
+ var prop;
+ if ('src' in obj || 'dest' in obj) {
+ files.push(obj);
+ }
+ });
+
+ if (files.length === 0) {
+ return [];
+ }
+
+ files = _(files).chain().forEach(function(obj) {
+ if (!('src' in obj) || !obj.src) { return; }
+ // Normalize .src properties to flattened array.
+ if (Array.isArray(obj.src)) {
+ obj.src = _.flatten(obj.src);
+ } else {
+ obj.src = [obj.src];
+ }
+ }).map(function(obj) {
+ // Build options object, removing unwanted properties.
+ var expandOptions = _.extend({}, obj);
+ delete expandOptions.src;
+ delete expandOptions.dest;
+
+ // Expand file mappings.
+ if (obj.expand) {
+ return file.expandMapping(obj.src, obj.dest, expandOptions).map(function(mapObj) {
+ // Copy obj properties to result.
+ var result = _.extend({}, obj);
+ // Make a clone of the orig obj available.
+ result.orig = _.extend({}, obj);
+ // Set .src and .dest, processing both as templates.
+ result.src = mapObj.src;
+ result.dest = mapObj.dest;
+ // Remove unwanted properties.
+ ['expand', 'cwd', 'flatten', 'rename', 'ext'].forEach(function(prop) {
+ delete result[prop];
+ });
+ return result;
+ });
+ }
+
+ // Copy obj properties to result, adding an .orig property.
+ var result = _.extend({}, obj);
+ // Make a clone of the orig obj available.
+ result.orig = _.extend({}, obj);
+
+ if ('src' in result) {
+ // Expose an expand-on-demand getter method as .src.
+ Object.defineProperty(result, 'src', {
+ enumerable: true,
+ get: function fn() {
+ var src;
+ if (!('result' in fn)) {
+ src = obj.src;
+ // If src is an array, flatten it. Otherwise, make it into an array.
+ src = Array.isArray(src) ? _.flatten(src) : [src];
+ // Expand src files, memoizing result.
+ fn.result = file.expand(expandOptions, src);
+ }
+ return fn.result;
+ }
+ });
+ }
+
+ if ('dest' in result) {
+ result.dest = obj.dest;
+ }
+
+ return result;
+ }).flatten().value();
+
+ return files;
+}; \ No newline at end of file
diff --git a/node_modules/archiver-utils/index.js b/node_modules/archiver-utils/index.js
new file mode 100644
index 000000000..c1607f81d
--- /dev/null
+++ b/node_modules/archiver-utils/index.js
@@ -0,0 +1,156 @@
+/**
+ * archiver-utils
+ *
+ * Copyright (c) 2015 Chris Talkington.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/archiver-utils/blob/master/LICENSE
+ */
+var fs = require('graceful-fs');
+var path = require('path');
+var nutil = require('util');
+var lazystream = require('lazystream');
+var normalizePath = require('normalize-path');
+var _ = require('lodash');
+
+var Stream = require('stream').Stream;
+var PassThrough = require('readable-stream').PassThrough;
+
+var utils = module.exports = {};
+utils.file = require('./file.js');
+
+function assertPath(path) {
+ if (typeof path !== 'string') {
+ throw new TypeError('Path must be a string. Received ' + nutils.inspect(path));
+ }
+}
+
+utils.collectStream = function(source, callback) {
+ var collection = [];
+ var size = 0;
+
+ source.on('error', callback);
+
+ source.on('data', function(chunk) {
+ collection.push(chunk);
+ size += chunk.length;
+ });
+
+ source.on('end', function() {
+ var buf = new Buffer(size);
+ var offset = 0;
+
+ collection.forEach(function(data) {
+ data.copy(buf, offset);
+ offset += data.length;
+ });
+
+ callback(null, buf);
+ });
+};
+
+utils.dateify = function(dateish) {
+ dateish = dateish || new Date();
+
+ if (dateish instanceof Date) {
+ dateish = dateish;
+ } else if (typeof dateish === 'string') {
+ dateish = new Date(dateish);
+ } else {
+ dateish = new Date();
+ }
+
+ return dateish;
+};
+
+// this is slightly different from lodash version
+utils.defaults = function(object, source, guard) {
+ var args = arguments;
+ args[0] = args[0] || {};
+
+ return _.defaults.apply(_, args);
+};
+
+utils.isStream = function(source) {
+ return source instanceof Stream;
+};
+
+utils.lazyReadStream = function(filepath) {
+ return new lazystream.Readable(function() {
+ return fs.createReadStream(filepath);
+ });
+};
+
+utils.normalizeInputSource = function(source) {
+ if (source === null) {
+ return new Buffer(0);
+ } else if (typeof source === 'string') {
+ return new Buffer(source);
+ } else if (utils.isStream(source) && !source._readableState) {
+ var normalized = new PassThrough();
+ source.pipe(normalized);
+
+ return normalized;
+ }
+
+ return source;
+};
+
+utils.sanitizePath = function(filepath) {
+ return normalizePath(filepath, false).replace(/^\w+:/, '').replace(/^(\.\.\/|\/)+/, '');
+};
+
+utils.trailingSlashIt = function(str) {
+ return str.slice(-1) !== '/' ? str + '/' : str;
+};
+
+utils.unixifyPath = function(filepath) {
+ return normalizePath(filepath, false).replace(/^\w+:/, '');
+};
+
+utils.walkdir = function(dirpath, base, callback) {
+ var results = [];
+
+ if (typeof base === 'function') {
+ callback = base;
+ base = dirpath;
+ }
+
+ fs.readdir(dirpath, function(err, list) {
+ var i = 0;
+ var file;
+ var filepath;
+
+ if (err) {
+ return callback(err);
+ }
+
+ (function next() {
+ file = list[i++];
+
+ if (!file) {
+ return callback(null, results);
+ }
+
+ filepath = path.join(dirpath, file);
+
+ fs.stat(filepath, function(err, stats) {
+ results.push({
+ path: filepath,
+ relative: path.relative(base, filepath).replace(/\\/g, '/'),
+ stats: stats
+ });
+
+ if (stats && stats.isDirectory()) {
+ utils.walkdir(filepath, base, function(err, res) {
+ res.forEach(function(dirEntry) {
+ results.push(dirEntry);
+ });
+ next();
+ });
+ } else {
+ next();
+ }
+ });
+ })();
+ });
+};
diff --git a/node_modules/archiver-utils/package.json b/node_modules/archiver-utils/package.json
new file mode 100644
index 000000000..97c6abde9
--- /dev/null
+++ b/node_modules/archiver-utils/package.json
@@ -0,0 +1,51 @@
+{
+ "name": "archiver-utils",
+ "version": "1.3.0",
+ "license": "MIT",
+ "description": "utility functions for archiver",
+ "homepage": "https://github.com/archiverjs/archiver-utils",
+ "author": {
+ "name": "Chris Talkington",
+ "url": "http://christalkington.com/"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/archiverjs/archiver-utils.git"
+ },
+ "bugs": {
+ "url": "https://github.com/archiverjs/archiver-utils/issues"
+ },
+ "homepage": "https://github.com/archiverjs/archiver-utils#readme",
+ "keywords": [
+ "archiver",
+ "utils"
+ ],
+ "main": "index.js",
+ "files": [
+ "index.js",
+ "file.js"
+ ],
+ "engines": {
+ "node": ">= 0.10.0"
+ },
+ "scripts": {
+ "test": "mocha --reporter dot"
+ },
+ "dependencies": {
+ "glob": "^7.0.0",
+ "graceful-fs": "^4.1.0",
+ "lazystream": "^1.0.0",
+ "lodash": "^4.8.0",
+ "normalize-path": "^2.0.0",
+ "readable-stream": "^2.0.0"
+ },
+ "devDependencies": {
+ "chai": "^3.4.0",
+ "mocha": "^2.3.3",
+ "rimraf": "^2.4.2",
+ "mkdirp": "^0.5.0"
+ },
+ "publishConfig": {
+ "registry": "https://registry.npmjs.org/"
+ }
+} \ No newline at end of file