Galerie und tage

This commit is contained in:
2021-11-23 17:56:26 +01:00
parent ff35366279
commit 5f873bee89
4693 changed files with 149659 additions and 301447 deletions

185
node_modules/bin-build/index.js generated vendored
View File

@@ -1,43 +1,170 @@
'use strict';
const decompress = require('decompress');
const download = require('download');
const execa = require('execa');
const pMapSeries = require('p-map-series');
const tempfile = require('tempfile');
var fs = require('fs');
var archiveType = require('archive-type');
var execSeries = require('exec-series');
var Decompress = require('decompress');
var Download = require('download');
var rimraf = require('rimraf');
var tempfile = require('tempfile');
var urlRegex = require('url-regex');
const exec = (cmd, cwd) => pMapSeries(cmd, x => execa.shell(x, {cwd}));
/**
* Initialize new `BinBuild`
*
* @param {Object} opts
* @api public
*/
exports.directory = (dir, cmd) => {
if (typeof dir !== 'string') {
return Promise.reject(new TypeError(`Expected a \`string\`, got \`${typeof dir}\``));
function BinBuild(opts) {
if (!(this instanceof BinBuild)) {
return new BinBuild(opts);
}
return exec(cmd, dir);
};
this.opts = opts || {};
this.tmp = tempfile();
exports.file = (file, cmd, opts) => {
opts = Object.assign({strip: 1}, opts);
if (this.opts.strip <= 0) {
this.opts.strip = 0;
} else if (!this.opts.strip) {
this.opts.strip = 1;
}
}
if (typeof file !== 'string') {
return Promise.reject(new TypeError(`Expected a \`string\`, got \`${typeof file}\``));
module.exports = BinBuild;
/**
* Define the source archive to download
*
* @param {String} str
* @api public
*/
BinBuild.prototype.src = function (str) {
if (!arguments.length) {
return this._src;
}
const tmp = tempfile();
return decompress(file, tmp, opts).then(() => exec(cmd, tmp));
this._src = str;
return this;
};
exports.url = (url, cmd, opts) => {
opts = Object.assign({
/**
* Add a command to run
*
* @param {String} str
* @api public
*/
BinBuild.prototype.cmd = function (str) {
if (!arguments.length) {
return this._cmd;
}
this._cmd = this._cmd || [];
this._cmd.push(str);
return this;
};
/**
* Build
*
* @param {Function} cb
* @api public
*/
BinBuild.prototype.run = function (cb) {
cb = cb || function () {};
if (urlRegex().test(this.src())) {
return this.download(function (err) {
if (err) {
cb(err);
return;
}
this.exec(this.tmp, cb);
}.bind(this));
}
fs.readFile(this.src(), function (err, data) {
if (err && err.code !== 'EISDIR') {
cb(err);
return;
}
if (archiveType(data)) {
this.extract(function (err) {
if (err) {
cb(err);
return;
}
this.exec(this.tmp, cb);
}.bind(this));
return;
}
this.exec(this.src(), cb);
}.bind(this));
};
/**
* Execute commands
*
* @param {String} cwd
* @param {Function} cb
* @api private
*/
BinBuild.prototype.exec = function (cwd, cb) {
execSeries(this.cmd(), {cwd: cwd}, function (err) {
if (err) {
err.message = [this.cmd().join(' && '), err.message].join('\n');
cb(err);
return;
}
rimraf(this.tmp, cb);
}.bind(this));
};
/**
* Decompress source
*
* @param {Function} cb
* @api private
*/
BinBuild.prototype.extract = function (cb) {
var decompress = new Decompress({
mode: '777',
strip: this.opts.strip
});
decompress
.src(this.src())
.dest(this.tmp)
.run(cb);
};
/**
* Download source file
*
* @param {Function} cb
* @api private
*/
BinBuild.prototype.download = function (cb) {
var download = new Download({
strip: this.opts.strip,
extract: true,
strip: 1
}, opts);
mode: '777'
});
if (typeof url !== 'string') {
return Promise.reject(new TypeError(`Expected a \`string\`, got \`${typeof url}\``));
}
const tmp = tempfile();
return download(url, tmp, opts).then(() => exec(cmd, tmp));
download
.get(this.src())
.dest(this.tmp)
.run(cb);
};