Galerie und tage
This commit is contained in:
168
node_modules/exec-buffer/index.js
generated
vendored
168
node_modules/exec-buffer/index.js
generated
vendored
@@ -1,45 +1,145 @@
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const execa = require('execa');
|
||||
const pFinally = require('p-finally');
|
||||
const pify = require('pify');
|
||||
const rimraf = require('rimraf');
|
||||
const tempfile = require('tempfile');
|
||||
|
||||
const fsP = pify(fs);
|
||||
const rmP = pify(rimraf);
|
||||
const input = Symbol('inputPath');
|
||||
const output = Symbol('outputPath');
|
||||
var execFile = require('child_process').execFile;
|
||||
var fs = require('fs');
|
||||
var rm = require('rimraf');
|
||||
var tempfile = require('tempfile');
|
||||
|
||||
module.exports = opts => {
|
||||
opts = Object.assign({}, opts);
|
||||
/**
|
||||
* Run a buffer through a child process
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
if (!Buffer.isBuffer(opts.input)) {
|
||||
return Promise.reject(new Error('Input is required'));
|
||||
function ExecBuffer() {
|
||||
if (!(this instanceof ExecBuffer)) {
|
||||
return new ExecBuffer();
|
||||
}
|
||||
|
||||
if (typeof opts.bin !== 'string') {
|
||||
return Promise.reject(new Error('Binary is required'));
|
||||
this.src(tempfile());
|
||||
this.dest(tempfile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a child process to use
|
||||
*
|
||||
* @param {String} bin
|
||||
* @param {Array} args
|
||||
* @api public
|
||||
*/
|
||||
|
||||
ExecBuffer.prototype.use = function (bin, args) {
|
||||
if (!arguments.length) {
|
||||
return this._use;
|
||||
}
|
||||
|
||||
if (!Array.isArray(opts.args)) {
|
||||
return Promise.reject(new Error('Arguments are required'));
|
||||
}
|
||||
this._use = {
|
||||
args: args,
|
||||
bin: bin
|
||||
};
|
||||
|
||||
const inputPath = opts.inputPath || tempfile();
|
||||
const outputPath = opts.outputPath || tempfile();
|
||||
|
||||
opts.args = opts.args.map(x => x === input ? inputPath : x === output ? outputPath : x);
|
||||
|
||||
const promise = fsP.writeFile(inputPath, opts.input)
|
||||
.then(() => execa(opts.bin, opts.args))
|
||||
.then(() => fsP.readFile(outputPath));
|
||||
|
||||
return pFinally(promise, () => Promise.all([
|
||||
rmP(inputPath),
|
||||
rmP(outputPath)
|
||||
]));
|
||||
return this;
|
||||
};
|
||||
|
||||
module.exports.input = input;
|
||||
module.exports.output = output;
|
||||
/**
|
||||
* Get or set the temp source path
|
||||
*
|
||||
* @param {String} path
|
||||
* @api public
|
||||
*/
|
||||
|
||||
ExecBuffer.prototype.src = function (path) {
|
||||
if (!arguments.length) {
|
||||
return this._src;
|
||||
}
|
||||
|
||||
this._src = path;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get or set the temp destination path
|
||||
*
|
||||
* @param {String} path
|
||||
* @api public
|
||||
*/
|
||||
|
||||
ExecBuffer.prototype.dest = function (path) {
|
||||
if (!arguments.length) {
|
||||
return this._dest;
|
||||
}
|
||||
|
||||
this._dest = path;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Run buffer through the child process
|
||||
*
|
||||
* @param {Buffer} buf
|
||||
* @param {Function} cb
|
||||
* @api public
|
||||
*/
|
||||
|
||||
ExecBuffer.prototype.run = function (buf, cb) {
|
||||
fs.writeFile(this.src(), buf, function (err) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
execFile(this.use().bin, this.use().args, function (err, stdout, stderr) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
fs.readFile(this.dest(), function (err, data) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
this.cleanup(function (err) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
cb(null, data, stderr);
|
||||
});
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Cleanup temporary files
|
||||
*
|
||||
* @param {Function} cb
|
||||
* @api private
|
||||
*/
|
||||
|
||||
ExecBuffer.prototype.cleanup = function (cb) {
|
||||
rm(this.src(), function (err) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
rm(this.dest(), function (err) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
cb();
|
||||
});
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Module exports
|
||||
*/
|
||||
|
||||
module.exports = ExecBuffer;
|
||||
|
||||
22
node_modules/exec-buffer/license
generated
vendored
22
node_modules/exec-buffer/license
generated
vendored
@@ -1,9 +1,21 @@
|
||||
MIT License
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com> (github.com/kevva)
|
||||
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:
|
||||
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 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.
|
||||
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.
|
||||
|
||||
79
node_modules/exec-buffer/package.json
generated
vendored
79
node_modules/exec-buffer/package.json
generated
vendored
@@ -1,80 +1,33 @@
|
||||
{
|
||||
"_from": "exec-buffer@^3.0.0",
|
||||
"_id": "exec-buffer@3.2.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-wsiD+2Tp6BWHoVv3B+5Dcx6E7u5zky+hUwOHjuH2hKSLR3dvRmX8fk8UD8uqQixHs4Wk6eDmiegVrMPjKj7wpA==",
|
||||
"_location": "/exec-buffer",
|
||||
"_phantomChildren": {
|
||||
"is-stream": "1.1.0",
|
||||
"lru-cache": "4.1.5",
|
||||
"npm-run-path": "2.0.2",
|
||||
"p-finally": "1.0.0",
|
||||
"shebang-command": "1.2.0",
|
||||
"signal-exit": "3.0.3",
|
||||
"strip-eof": "1.0.0",
|
||||
"which": "1.3.1"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "exec-buffer@^3.0.0",
|
||||
"name": "exec-buffer",
|
||||
"escapedName": "exec-buffer",
|
||||
"rawSpec": "^3.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^3.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/imagemin-optipng"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/exec-buffer/-/exec-buffer-3.2.0.tgz",
|
||||
"_shasum": "b1686dbd904c7cf982e652c1f5a79b1e5573082b",
|
||||
"_spec": "exec-buffer@^3.0.0",
|
||||
"_where": "/var/www/html/jason/WeihnachtenMelly/node_modules/imagemin-optipng",
|
||||
"name": "exec-buffer",
|
||||
"version": "2.0.1",
|
||||
"description": "Run a buffer through a child process",
|
||||
"license": "MIT",
|
||||
"repository": "kevva/exec-buffer",
|
||||
"author": {
|
||||
"name": "Kevin Mårtensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "https://github.com/kevva"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/kevva/exec-buffer/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"execa": "^0.7.0",
|
||||
"p-finally": "^1.0.0",
|
||||
"pify": "^3.0.0",
|
||||
"rimraf": "^2.5.4",
|
||||
"tempfile": "^2.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Run a buffer through a child process",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"gifsicle": "^3.0.4",
|
||||
"is-gif": "^1.0.0",
|
||||
"path-exists": "^3.0.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/test.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/kevva/exec-buffer#readme",
|
||||
"keywords": [
|
||||
"buffer",
|
||||
"exec"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "exec-buffer",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/kevva/exec-buffer.git"
|
||||
"dependencies": {
|
||||
"rimraf": "^2.2.6",
|
||||
"tempfile": "^1.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "3.2.0"
|
||||
"devDependencies": {
|
||||
"ava": "^0.0.4",
|
||||
"gifsicle": "^2.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
80
node_modules/exec-buffer/readme.md
generated
vendored
80
node_modules/exec-buffer/readme.md
generated
vendored
@@ -2,80 +2,82 @@
|
||||
|
||||
> Run a Buffer through a child process
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```ba
|
||||
$ npm install --save exec-buffer
|
||||
```
|
||||
$ npm install exec-buffer
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const fs = require('fs');
|
||||
const execBuffer = require('exec-buffer');
|
||||
const gifsicle = require('gifsicle').path;
|
||||
var ExecBuffer = require('exec-buffer');
|
||||
var fs = require('fs');
|
||||
var gifsicle = require('gifsicle').path;
|
||||
|
||||
execBuffer({
|
||||
input: fs.readFileSync('test.gif'),
|
||||
bin: gifsicle,
|
||||
args: ['-o', execBuffer.output, execBuffer.input]
|
||||
}).then(data => {
|
||||
console.log(data);
|
||||
//=> <Buffer 47 49 46 38 37 61 ...>
|
||||
var execBuffer = new ExecBuffer();
|
||||
|
||||
execBuffer.use(gifsicle, ['-o', execBuffer.dest(), execBuffer.src()]);
|
||||
execBuffer.run(fs.readFileSync('test.gif'), function (err, data) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
//=> <Buffer 47 49 46 38 37 61 ...>
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### execBuffer(options)
|
||||
### new ExecBuffer()
|
||||
|
||||
#### options
|
||||
Creates a new `ExecBuffer` instance.
|
||||
|
||||
Type: `Object`
|
||||
### .use(bin, args)
|
||||
|
||||
##### input
|
||||
#### bin
|
||||
|
||||
Type: `Buffer`
|
||||
|
||||
The `Buffer` to be ran through the child process.
|
||||
|
||||
##### bin
|
||||
|
||||
Type: `string`
|
||||
Type: `String`
|
||||
|
||||
Path to the binary.
|
||||
|
||||
##### args
|
||||
#### args
|
||||
|
||||
Type: `Array`
|
||||
|
||||
Arguments to run the binary with.
|
||||
|
||||
#### inputPath
|
||||
### .src(path)
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `tempfile()`
|
||||
#### path
|
||||
|
||||
Where `input` will be written to. In most cases you don't need to set this.
|
||||
Type: `String`
|
||||
|
||||
#### outputPath
|
||||
Set or get the temporary source path.
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `tempfile()`
|
||||
### .dest(path)
|
||||
|
||||
Where output file will be written to. In most cases you don't need to set this.
|
||||
#### path
|
||||
|
||||
### execBuffer.input
|
||||
Type: `String`
|
||||
|
||||
Returns a temporary path to where the input file will be written.
|
||||
Set or get the temporary destination path.
|
||||
|
||||
### execBuffer.output
|
||||
### .run(buf, cb)
|
||||
|
||||
Returns a temporary path to where the output file will be written.
|
||||
#### buf
|
||||
|
||||
Type: `Buffer`
|
||||
|
||||
The `Buffer` to be ran through the child process.
|
||||
|
||||
#### cb(err, data, stderr)
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Returns a `Buffer` with the new `data` and any `stderr` output.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
Reference in New Issue
Block a user