update @actions/tool-cache, install semver, nock
This commit is contained in:
parent
74d434c5ca
commit
4c6749115a
678 changed files with 39259 additions and 14619 deletions
52
node_modules/nock/lib/delayed_body.js
generated
vendored
Normal file
52
node_modules/nock/lib/delayed_body.js
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
'use strict'
|
||||
|
||||
/**
|
||||
* Creates a stream which becomes the response body of the interceptor when a
|
||||
* delay is set. The stream outputs the intended body and EOF after the delay.
|
||||
*
|
||||
* @param {String|Buffer|Stream} body - the body to write/pipe out
|
||||
* @param {Integer} ms - The delay in milliseconds
|
||||
* @constructor
|
||||
*/
|
||||
|
||||
const { Transform } = require('stream')
|
||||
const common = require('./common')
|
||||
|
||||
module.exports = class DelayedBody extends Transform {
|
||||
constructor(ms, body) {
|
||||
super()
|
||||
|
||||
const self = this
|
||||
let data = ''
|
||||
let ended = false
|
||||
|
||||
if (common.isStream(body)) {
|
||||
body.on('data', function(chunk) {
|
||||
data += Buffer.isBuffer(chunk) ? chunk.toString() : chunk
|
||||
})
|
||||
|
||||
body.once('end', function() {
|
||||
ended = true
|
||||
})
|
||||
|
||||
body.resume()
|
||||
}
|
||||
|
||||
// TODO: This would be more readable if the stream case were moved into
|
||||
// the `if` statement above.
|
||||
common.setTimeout(function() {
|
||||
if (common.isStream(body) && !ended) {
|
||||
body.once('end', function() {
|
||||
self.end(data)
|
||||
})
|
||||
} else {
|
||||
self.end(data || body)
|
||||
}
|
||||
}, ms)
|
||||
}
|
||||
|
||||
_transform(chunk, encoding, cb) {
|
||||
this.push(chunk)
|
||||
process.nextTick(cb)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue