Skip to content

Commit

Permalink
Merge pull request #124 from quentinrossetti/chore-node18
Browse files Browse the repository at this point in the history
Chore node18
  • Loading branch information
Quentin Rossetti authored Oct 31, 2022
2 parents 761ff84 + 2f2146c commit 4186b29
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/node:12.22
- image: circleci/node

working_directory: ~/node-7z

Expand Down
22 changes: 12 additions & 10 deletions src/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ export const onStdoutFactory = ({ Maybe }) => (stream, chunk) => {
return stream
}

// Progress as a percentage is only displayed to stdout when the `-bsp1`
// switch is specified. Progress can has several forms:
// - only percent: ` 0%`
// - with file count: ` 23% 4`
// - with file name: ` 23% 4 file.txt`
if (stream._isProgressFlag) {
const bodyProgress = Maybe.progress(stream, line)
if (bodyProgress) {
return stream
}
}

// Optimization: Continue to the next line. At this point if the stream is
// in stage BODY all data carried by the current line has been processed.
const stageBody = (stream._stage === STAGE_BODY)
Expand All @@ -72,16 +84,6 @@ export const onStdoutFactory = ({ Maybe }) => (stream, chunk) => {
return stream
}

// Progress as a percentage is only displayed to stdout when the `-bsp1`
// switch is specified. Progress can has several forms:
// - only percent: ` 0%`
// - with file count: ` 23% 4`
// - with file name: ` 23% 4 file.txt`
const bodyProgress = Maybe.progress(stream, line)
if (bodyProgress) {
return stream
}

Maybe.bodyData(stream, line)
return stream
}
Expand Down
5 changes: 2 additions & 3 deletions src/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import split2 from 'split2'
import { spawn } from 'child_process'
import { Readable } from 'stream'
import { STAGE_HEADERS } from './references.js'
import { LINE_SPLIT } from './regexp.js'
const debug = libdebug('node-7z')

export const createFactory = ({
Expand Down Expand Up @@ -66,10 +65,10 @@ export const listenFactory = ({
debug('lifecycle: listen')
stream._childProcess.on('error', err => errorHandler(stream, err))
stream._childProcess.stderr
.pipe(split2(LINE_SPLIT))
.pipe(split2())
.on('data', chunk => stderrHandler(stream, chunk))
stream._childProcess.stdout
.pipe(split2(LINE_SPLIT))
.pipe(split2())
.on('data', chunk => stdoutHandler(stream, chunk))
stream._childProcess.on('close', () => endHandler(stream))
return stream
Expand Down
1 change: 0 additions & 1 deletion src/regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

export const LINE_SPLIT = new RegExp('\n|\r\n|\x08+|\r +\r')
export const BODY_PROGRESS = new RegExp('^ *(?<percent>\\d+)% ?(?<fileCount>\\d+)? ?(?<file>.*)$')
export const BODY_SYMBOL_FILE = new RegExp('^(?<symbol>[=TU+R.-]) (?<file>.+)$')
export const BODY_HASH = new RegExp('^(?<hash>\\S+)? +(?<size>\\d*) +(?<file>.+)$')
Expand Down

0 comments on commit 4186b29

Please sign in to comment.