Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove event-stream dependency #1305

Merged
merged 12 commits into from
Nov 26, 2018
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"custom-event-polyfill": "^1.0.6",
"detect-browser": "^3.0.0",
"eslint": "^5.9.0",
"event-stream": "3.3.4",
"execa": "^1.0.0",
"git-state": "^4.0.0",
"gulp": "^4.0.0",
Expand Down
9 changes: 4 additions & 5 deletions utils/execute.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
const execa = require('execa')
const es = require('event-stream')
const streamArray = require('./stream-array')

module.exports = function execute (command, { skipLogging } = {}) {
const proc = execa.shell(command)

if (!skipLogging) {
const formatLine = (line, label) => ` (pid:${proc.pid})\t[${label}]\t${line}\n`
const formatStream = (stream, label) => stream
.pipe(es.split())
.pipe(es.map((line, cb) => cb(null, formatLine(line, label))))
.pipe(streamArray.split())
.pipe(streamArray.map(line => formatLine(line, label)))

process.stdout.write(formatLine(command, 'cmd'))
es.merge(formatStream(proc.stdout, 'out'), formatStream(proc.stderr, 'ERR'))
streamArray.merge(formatStream(proc.stdout, 'out'), formatStream(proc.stderr, 'ERR'))
.pipe(process.stdout)
}

Expand Down
50 changes: 50 additions & 0 deletions utils/stream-array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

const { Duplex } = require('stream')

module.exports.map = function (mapfn) {
const stream = new Duplex({
write (chunk, encoding, callback) {
this.push(mapfn(chunk))
callback()
},
read () {}
})
return stream
}

module.exports.split = function () {
const stream = new Duplex({
write (chunk, encoding, callback) {
this.buffer = (this.buffer || '') + chunk.toString()
if (/\r?\n/.test(chunk.toString())) {
let splitChunks = this.buffer.split(/\r?\n/)
for (let i = 0; i < splitChunks.length - 1; i++) {
this.push(splitChunks[i])
}
this.buffer = splitChunks[splitChunks.length -1]
}
callback()
},
read () {}
})
return stream
}

module.exports.merge = function (/* streams... */) {
let toMerge = [].slice.call(arguments)

const stream = new Duplex({
write (chunk, encoding, callback) {
this.push(chunk)
callback()
},
read() {}
})

if (toMerge.length) {
toMerge.forEach(function (e) {
e.pipe(stream, { end: false })
})
}
return stream
}
73 changes: 9 additions & 64 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2965,7 +2965,7 @@ debug@^4.0.0, debug@^4.0.1:
dependencies:
ms "^2.1.1"

debuglog@*, debuglog@^1.0.1:
debuglog@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
Expand Down Expand Up @@ -3245,7 +3245,7 @@ duplexer3@^0.1.4:
resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2"
integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=

duplexer@^0.1.1, duplexer@~0.1.1:
duplexer@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"
integrity sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=
Expand Down Expand Up @@ -3726,19 +3726,6 @@ event-emitter@~0.3.5:
d "1"
es5-ext "~0.10.14"

event-stream@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-4.0.1.tgz#4092808ec995d0dd75ea4580c1df6a74db2cde65"
integrity sha512-qACXdu/9VHPBzcyhdOWR5/IahhGMf0roTeZJfzz077GwylcDd90yOHLouhmv7GJ5XzPi6ekaQWd8AvPP2nOvpA==
dependencies:
duplexer "^0.1.1"
from "^0.1.7"
map-stream "0.0.7"
pause-stream "^0.0.11"
split "^1.0.1"
stream-combiner "^0.2.2"
through "^2.3.8"

eventemitter3@1.x.x:
version "1.2.0"
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-1.2.0.tgz#1c86991d816ad1e504750e73874224ecf3bec508"
Expand Down Expand Up @@ -4254,11 +4241,6 @@ from2@^2.1.0, from2@^2.1.1:
inherits "^2.0.1"
readable-stream "^2.0.0"

from@^0.1.7:
version "0.1.7"
resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe"
integrity sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=

front-matter@2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/front-matter/-/front-matter-2.1.2.tgz#f75983b9f2f413be658c93dfd7bd8ce4078f5cdb"
Expand Down Expand Up @@ -5249,7 +5231,7 @@ import-lazy@^2.1.0:
resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43"
integrity sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=

imurmurhash@*, imurmurhash@^0.1.4:
imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
Expand Down Expand Up @@ -6348,11 +6330,6 @@ lodash._basecopy@^3.0.0:
resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"
integrity sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=

lodash._baseindexof@*:
version "3.1.0"
resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=

lodash._basetostring@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz#d1861d877f824a52f669832dcaf3ee15566a07d5"
Expand All @@ -6371,29 +6348,12 @@ lodash._basevalues@^3.0.0:
resolved "https://registry.yarnpkg.com/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz#5b775762802bde3d3297503e26300820fdf661b7"
integrity sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=

lodash._bindcallback@*:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4=

lodash._cacheindexof@*:
version "3.0.2"
resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=

lodash._createcache@*:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=
dependencies:
lodash._getnative "^3.0.0"

lodash._createset@~4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY=

lodash._getnative@*, lodash._getnative@^3.0.0:
lodash._getnative@^3.0.0:
version "3.9.1"
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=
Expand Down Expand Up @@ -6504,7 +6464,7 @@ lodash.mergewith@^4.6.0:
resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz#639057e726c3afbdb3e7d42741caa8d6e4335927"
integrity sha512-eWw5r+PYICtEBgrBE5hhlT6aAa75f411bgDz/ZL2KZqYV03USvucsxcHUIlGTDTECs1eunpI7HOV7U+WLDvNdQ==

lodash.restparam@*, lodash.restparam@^3.0.0:
lodash.restparam@^3.0.0:
version "3.6.1"
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=
Expand Down Expand Up @@ -6720,7 +6680,7 @@ map-obj@^2.0.0:
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9"
integrity sha1-plzSkIepJZi4eRJXpSPgISIqwfk=

map-stream@0.0.7, map-stream@~0.0.7:
map-stream@~0.0.7:
version "0.0.7"
resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.0.7.tgz#8a1f07896d82b10926bd3744a2420009f88974a8"
integrity sha1-ih8HiW2CsQkmvTdEokIACfiJdKg=
Expand Down Expand Up @@ -8157,13 +8117,6 @@ path-type@^3.0.0:
dependencies:
pify "^3.0.0"

pause-stream@^0.0.11:
version "0.0.11"
resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445"
integrity sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=
dependencies:
through "~2.3"

pbkdf2@^3.0.3:
version "3.0.17"
resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.17.tgz#976c206530617b14ebb32114239f7b09336e93a6"
Expand Down Expand Up @@ -8724,7 +8677,7 @@ readable-stream@~1.1.10, readable-stream@~1.1.9:
isarray "0.0.1"
string_decoder "~0.10.x"

readdir-scoped-modules@*, readdir-scoped-modules@^1.0.0:
readdir-scoped-modules@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/readdir-scoped-modules/-/readdir-scoped-modules-1.0.2.tgz#9fafa37d286be5d92cbaebdee030dc9b5f406747"
integrity sha1-n6+jfShr5dksuuve4DDcm19AZ0c=
Expand Down Expand Up @@ -9804,7 +9757,7 @@ split2@~1.0.0:
dependencies:
through2 "~2.0.0"

split@^1.0.0, split@^1.0.1:
split@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/split/-/split-1.0.1.tgz#605bd9be303aa59fb35f9229fbea0ddec9ea07d9"
integrity sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==
Expand Down Expand Up @@ -9896,14 +9849,6 @@ stream-combiner2@~1.1.1:
duplexer2 "~0.1.0"
readable-stream "^2.0.2"

stream-combiner@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/stream-combiner/-/stream-combiner-0.2.2.tgz#aec8cbac177b56b6f4fa479ced8c1912cee52858"
integrity sha1-rsjLrBd7Vrb0+kec7YwZEs7lKFg=
dependencies:
duplexer "~0.1.1"
through "~2.3.4"

stream-each@^1.1.0:
version "1.2.3"
resolved "https://registry.yarnpkg.com/stream-each/-/stream-each-1.2.3.tgz#ebe27a0c389b04fbcc233642952e10731afa9bae"
Expand Down Expand Up @@ -10239,7 +10184,7 @@ through2@^2.0.0, through2@^2.0.1, through2@^2.0.2, through2@^2.0.3, through2@~2.
readable-stream "~2.3.6"
xtend "~4.0.1"

through@2, "through@>=2.2.7 <3", through@^2.3.6, through@^2.3.8, through@~2.3, through@~2.3.4, through@~2.3.8:
through@2, "through@>=2.2.7 <3", through@^2.3.6, through@~2.3.8:
version "2.3.8"
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
Expand Down