Skip to content

Commit

Permalink
remove bulk functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctalkington committed Jun 17, 2017
1 parent 962f956 commit 7ec0813
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 153 deletions.
89 changes: 0 additions & 89 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,95 +536,6 @@ Archiver.prototype.append = function(source, data) {
return this;
};

/**
* Appends multiple entries from passed array of src-dest mappings.
*
* A [lazystream]{@link https://github.com/jpommerening/node-lazystream} wrapper is
* used to prevent issues with open file limits.
*
* @deprecated 0.21.0
* @param {Object[]} mappings
* @param {(EntryData|Function)} mappings[].data See also {@link ZipEntryData}
* and {@link TarEntryData}.
* @param {(String|Array)} mappings[].src Pattern(s) to match, relative to the `cwd`.
* @param {String} mappings[].dest Destination path prefix.
* @param {Boolean} mappings[].expand Process a dynamic src-dest file mapping.
* @param {String} mappings[].cwd All `src` matches are relative to (but don't include)
* this path. requires `expand`.
* @param {String} mappings[].ext Replace any existing extension with this value in
* generated `dest` paths. requires `expand`.
* @param {String} mappings[].extDot Used to indicate where the period indicating
* the extension is located. requires `expand`.
* @param {String} mappings[].flatten Remove all path parts from generated `dest`
* paths. requires `expand`.
* @param {*} mappings[].* See [node-glob]{@link https://github.com/isaacs/node-glob#properties}
* and [minimatch]{@link https://github.com/isaacs/minimatch#properties} documentation
* for additional properties.
* @return {this}
*/
Archiver.prototype.bulk = function(mappings) {
if (process._loggedBulkDeprecation === false) {
process._loggedBulkDeprecation = true;
var warning = 'Archiver.bulk() deprecated since 0.21.0';
if (typeof process !== 'undefined' && typeof process.emitWarning !== 'undefined') {
process.emitWarning(warning, 'DeprecationWarning');
} else {
console.warn(warning);
}
}

if (this._state.finalize || this._state.aborted) {
this.emit('error', new Error('bulk: queue closed'));
return this;
}

if (!Array.isArray(mappings)) {
mappings = [mappings];
}

var self = this;
var files = util.file.normalizeFilesArray(mappings);

files.forEach(function(file){
var isExpandedPair = file.orig.expand || false;
var data = {};
var dataFunction = false;

if (typeof file.data === 'function') {
dataFunction = file.data;
} else if (typeof file.data === 'object') {
data = file.data;
}

file.src.forEach(function(filepath) {
var entryData = _.extend({}, data);
var entryName = isExpandedPair ? file.dest : (file.dest || '') + '/' + filepath;
entryData.name = util.sanitizePath(entryName);

if (entryData.name === '.') {
return;
}

try {
if (dataFunction) {
entryData = dataFunction(entryData);

if (typeof entryData !== 'object') {
throw new Error('bulk: invalid data returned from custom function');
}
}
} catch(e) {
self.emit('error', e);
return;
}

self._append(filepath, entryData);
});
});

return this;
};

/**
* Appends a directory and its files, recursively, given its dirpath.
*
Expand Down
64 changes: 0 additions & 64 deletions test/archiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,70 +253,6 @@ describe('archiver', function() {
});
});

describe('#bulk', function() {
var actual;
var archive;
var entries = {};

before(function(done) {
archive = archiver('json');
var testStream = new WriteStream('tmp/bulk.json');

testStream.on('close', function() {
actual = helpers.readJSON('tmp/bulk.json');

actual.forEach(function(entry) {
entries[entry.name] = entry;
});

done();
});

archive.pipe(testStream);

archive
.bulk([
{ expand: true, cwd: 'test/fixtures/directory/', src: '**', data: { prop: 'value' } },
{ expand: true, cwd: 'test/fixtures/directory/', src: '**', dest: 'directory/', data: function(data) {
data.funcProp = true;
return data;
}},
])
.finalize();
});

it('should append multiple entries', function() {
assert.isArray(actual);

assert.property(entries, 'level0.txt');
assert.property(entries, 'subdir/');
assert.property(entries, 'subdir/level1.txt');
assert.property(entries, 'subdir/subsub/');
assert.property(entries, 'subdir/subsub/level2.txt');

assert.property(entries, 'directory/level0.txt');
assert.property(entries, 'directory/subdir/');
assert.property(entries, 'directory/subdir/level1.txt');
assert.property(entries, 'directory/subdir/subsub/');
assert.property(entries, 'directory/subdir/subsub/level2.txt');
});

it('should support setting data properties', function() {
assert.property(entries, 'level0.txt');
assert.propertyVal(entries['level0.txt'], 'prop', 'value');
});

it('should support setting data properties via function', function() {
assert.property(entries, 'directory/level0.txt');
assert.propertyVal(entries['directory/level0.txt'], 'funcProp', true);
});

it('should retain directory permissions', function() {
assert.property(entries, 'subdir/');
assert.propertyVal(entries['subdir/'], 'mode', 493);
});
});

describe('#glob', function() {
var actual;
var archive;
Expand Down

0 comments on commit 7ec0813

Please sign in to comment.