Initial commit

This commit is contained in:
Developer
2025-04-21 16:03:20 +02:00
commit 2832896157
22874 changed files with 3092801 additions and 0 deletions

View File

@@ -0,0 +1,130 @@
'use strict';
var bufferToVinyl = require('buffer-to-vinyl');
var concatStream = require('concat-stream');
var streamCombiner = require('stream-combiner2');
var vinylFs = require('vinyl-fs');
var vinylAssign = require('vinyl-assign');
/**
* Initialize Decompress
*
* @param {Object} opts
* @api public
*/
function Decompress(opts) {
if (!(this instanceof Decompress)) {
return new Decompress(opts);
}
this.opts = opts || {};
this.streams = [];
}
/**
* Get or set the source files
*
* @param {Array|Buffer|String} file
* @api public
*/
Decompress.prototype.src = function (file) {
if (!arguments.length) {
return this._src;
}
this._src = file;
return this;
};
/**
* Get or set the destination folder
*
* @param {String} dir
* @api public
*/
Decompress.prototype.dest = function (dir) {
if (!arguments.length) {
return this._dest;
}
this._dest = dir;
return this;
};
/**
* Add a plugin to the middleware stack
*
* @param {Function} plugin
* @api public
*/
Decompress.prototype.use = function (plugin) {
this.streams.push(plugin);
return this;
};
/**
* Decompress archive
*
* @param {Function} cb
* @api public
*/
Decompress.prototype.run = function (cb) {
cb = cb || function () {};
var stream = this.createStream();
stream.on('error', cb);
stream.pipe(concatStream(cb.bind(null, null)));
};
/**
* Create stream
*
* @api private
*/
Decompress.prototype.createStream = function () {
this.streams.unshift(vinylAssign({extract: true}));
this.streams.unshift(this.getFiles());
if (this.streams.length === 2) {
this.use(Decompress.tar(this.opts));
this.use(Decompress.tarbz2(this.opts));
this.use(Decompress.targz(this.opts));
this.use(Decompress.zip(this.opts));
}
if (this.dest()) {
this.streams.push(vinylFs.dest(this.dest()));
}
return streamCombiner.obj(this.streams);
};
/**
* Get files
*
* @api private
*/
Decompress.prototype.getFiles = function () {
if (Buffer.isBuffer(this.src())) {
return bufferToVinyl.stream(this.src());
}
return vinylFs.src(this.src());
};
/**
* Module exports
*/
module.exports = Decompress;
module.exports.tar = require('decompress-tar');
module.exports.tarbz2 = require('decompress-tarbz2');
module.exports.targz = require('decompress-targz');
module.exports.zip = require('decompress-unzip');

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Kevin Mårtensson <kevinmartensson@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,81 @@
{
"_from": "decompress@^3.0.0",
"_id": "decompress@3.0.0",
"_inBundle": false,
"_integrity": "sha1-rx3VDQbjv8QyRh033hGzjA2ZG+0=",
"_location": "/decompress",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "decompress@^3.0.0",
"name": "decompress",
"escapedName": "decompress",
"rawSpec": "^3.0.0",
"saveSpec": null,
"fetchSpec": "^3.0.0"
},
"_requiredBy": [
"/bin-build",
"/gulp-decompress"
],
"_resolved": "https://registry.npmjs.org/decompress/-/decompress-3.0.0.tgz",
"_shasum": "af1dd50d06e3bfc432461d37de11b38c0d991bed",
"_spec": "decompress@^3.0.0",
"_where": "D:\\developments\\teaser-inertia\\nova-components\\NovaLeader\\node_modules\\bin-build",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "https://github.com/kevva"
},
"bugs": {
"url": "https://github.com/kevva/decompress/issues"
},
"bundleDependencies": false,
"dependencies": {
"buffer-to-vinyl": "^1.0.0",
"concat-stream": "^1.4.6",
"decompress-tar": "^3.0.0",
"decompress-tarbz2": "^3.0.0",
"decompress-targz": "^3.0.0",
"decompress-unzip": "^3.0.0",
"stream-combiner2": "^1.1.1",
"vinyl-assign": "^1.0.1",
"vinyl-fs": "^2.2.0"
},
"deprecated": false,
"description": "Extracting archives made easy",
"devDependencies": {
"ava": "0.2.0",
"rimraf": "^2.2.8",
"xo": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/kevva/decompress#readme",
"keywords": [
"bz2",
"bzip2",
"decompress",
"extract",
"tar",
"tar.bz",
"tar.gz",
"zip",
"unzip"
],
"license": "MIT",
"name": "decompress",
"repository": {
"type": "git",
"url": "git+https://github.com/kevva/decompress.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "3.0.0"
}

View File

@@ -0,0 +1,136 @@
# decompress [![Build Status](https://travis-ci.org/kevva/decompress.svg?branch=master)](https://travis-ci.org/kevva/decompress)
> Extracting archives made easy
*See [decompress-cli](https://github.com/kevva/decompress-cli) for the command-line version.*
## Install
```
$ npm install --save decompress
```
## Usage
```js
const Decompress = require('decompress');
new Decompress({mode: '755'})
.src('foo.zip')
.dest('dest')
.use(Decompress.zip({strip: 1}))
.run();
```
## API
### new Decompress(options)
Creates a new `Decompress` instance.
#### options.mode
Type: `string`
Set mode on the extracted files, i.e `{ mode: '755' }`.
#### options.strip
Type: `number`
Equivalent to `--strip-components` for tar.
### .src(files)
#### files
Type: `array`, `buffer` or `string`
Set the files to be extracted.
### .dest(path)
#### path
Type: `string`
Set the destination to where your file will be extracted to.
### .use(plugin)
#### plugin
Type: `function`
Add a `plugin` to the middleware stack.
### .run(callback)
Extract your file with the given settings.
#### callback(err, files)
Type: `function`
The callback will return an array of vinyl files in `files`.
## Plugins
The following [plugins](https://www.npmjs.org/browse/keyword/decompressplugin) are bundled with decompress:
* [tar](#tar) — Extract TAR files.
* [tar.bz2](#tarbz2) — Extract TAR.BZ files.
* [tar.gz](#targz) — Extract TAR.GZ files.
* [zip](#zip) — Extract ZIP files.
### .tar(options)
Extract TAR files.
```js
const Decompress = require('decompress');
new Decompress()
.use(Decompress.tar({strip: 1}));
```
### .tarbz2(options)
Extract TAR.BZ files.
```js
const Decompress = require('decompress');
new Decompress()
.use(Decompress.tarbz2({strip: 1}));
```
### .targz(options)
Extract TAR.GZ files.
```js
const Decompress = require('decompress');
new Decompress()
.use(Decompress.targz({strip: 1}));
```
### .zip(options)
Extract ZIP files.
```js
const Decompress = require('decompress');
new Decompress()
.use(Decompress.zip({strip: 1}));
```
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)