mirror of
https://github.com/deployphp/action.git
synced 2025-06-29 04:34:15 +00:00
Mark job as failed on error (#14)
* fix: set failed on subprocess error * chore: update dependencies
This commit is contained in:
parent
1f9078ddea
commit
9eab20634f
39 changed files with 281 additions and 1118 deletions
23
node_modules/get-stream/index.js
generated
vendored
23
node_modules/get-stream/index.js
generated
vendored
|
@ -1,8 +1,11 @@
|
|||
'use strict';
|
||||
const {constants: BufferConstants} = require('buffer');
|
||||
const pump = require('pump');
|
||||
const stream = require('stream');
|
||||
const {promisify} = require('util');
|
||||
const bufferStream = require('./buffer-stream');
|
||||
|
||||
const streamPipelinePromisified = promisify(stream.pipeline);
|
||||
|
||||
class MaxBufferError extends Error {
|
||||
constructor() {
|
||||
super('maxBuffer exceeded');
|
||||
|
@ -12,7 +15,7 @@ class MaxBufferError extends Error {
|
|||
|
||||
async function getStream(inputStream, options) {
|
||||
if (!inputStream) {
|
||||
return Promise.reject(new Error('Expected a stream'));
|
||||
throw new Error('Expected a stream');
|
||||
}
|
||||
|
||||
options = {
|
||||
|
@ -21,8 +24,8 @@ async function getStream(inputStream, options) {
|
|||
};
|
||||
|
||||
const {maxBuffer} = options;
|
||||
const stream = bufferStream(options);
|
||||
|
||||
let stream;
|
||||
await new Promise((resolve, reject) => {
|
||||
const rejectPromise = error => {
|
||||
// Don't retrieve an oversized buffer.
|
||||
|
@ -33,14 +36,14 @@ async function getStream(inputStream, options) {
|
|||
reject(error);
|
||||
};
|
||||
|
||||
stream = pump(inputStream, bufferStream(options), error => {
|
||||
if (error) {
|
||||
(async () => {
|
||||
try {
|
||||
await streamPipelinePromisified(inputStream, stream);
|
||||
resolve();
|
||||
} catch (error) {
|
||||
rejectPromise(error);
|
||||
return;
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
})();
|
||||
|
||||
stream.on('data', () => {
|
||||
if (stream.getBufferedLength() > maxBuffer) {
|
||||
|
@ -53,8 +56,6 @@ async function getStream(inputStream, options) {
|
|||
}
|
||||
|
||||
module.exports = getStream;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = getStream;
|
||||
module.exports.buffer = (stream, options) => getStream(stream, {...options, encoding: 'buffer'});
|
||||
module.exports.array = (stream, options) => getStream(stream, {...options, array: true});
|
||||
module.exports.MaxBufferError = MaxBufferError;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue