From 13acdd01584eaafa07cbfdbfdf5985678c0350c5 Mon Sep 17 00:00:00 2001 From: Quentin Rossetti Date: Mon, 3 Dec 2018 22:28:29 +0100 Subject: [PATCH] feat: Add a status for Symbol-file data events --- src/parser.js | 8 +++++++- src/references.js | 19 ++++++++++++++++--- test/func/update.spec.js | 21 ++++++++++----------- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/parser.js b/src/parser.js index 67fa003..f0a5045 100644 --- a/src/parser.js +++ b/src/parser.js @@ -1,5 +1,6 @@ import normalizePath from 'normalize-path' import { INFOS, BODY_PROGRESS, BODY_SYMBOL_FILE, BODY_HASH, INFOS_SPLIT, END_OF_STAGE_HYPHEN } from './regexp.js' +import { SYMBOL_OPERATIONS } from './references.js' // Infos about the opertation are given by 7z on the stdout. They can be: // - colon-seprated: `Creating archive: DirNew/BaseExt.7z` @@ -77,7 +78,12 @@ export function matchBodySymbol (stream, line) { const match = line.match(BODY_SYMBOL_FILE) if (match) { match.groups.file = normalizePath(match.groups.file) - return match.groups + const data = { + symbol: match.groups.symbol, + file: normalizePath(match.groups.file), + status: SYMBOL_OPERATIONS[match.groups.symbol] + } + return data } return null } diff --git a/src/references.js b/src/references.js index 67995e7..0cf3ff0 100644 --- a/src/references.js +++ b/src/references.js @@ -4,15 +4,17 @@ export const FLAGS = [ { type: 'bool', api: 'alternateStreamReplace', cli: 'snr' }, // Replace ':' character to '_' character in paths of alternate streams { type: 'bool', api: 'deleteFilesAfter', cli: 'sdel' }, // Delete files after compression { type: 'bool', api: 'fullyQualifiedPaths', cli: 'spf' }, // Use fully qualified file paths + { type: 'bool', api: 'hardlinks', cli: 'snh' }, // Store hard links as links (WIM and TAR formats only) { type: 'bool', api: 'largePages', cli: 'spl' }, // Set Large Pages mode { type: 'bool', api: 'latestTimeStamp', cli: 'stl' }, // Set archive timestamp from the most recently modified file { type: 'bool', api: 'noRootDuplication', cli: 'spe' }, // Eliminate duplication of root folder for extract command { type: 'bool', api: 'noWildcards', cli: 'spd' }, // Disable wildcard matching for file names - { type: 'bool', api: 'openFiles', cli: 'ssw' }, // Compress files open for writing - { type: 'bool', api: 'recursive', cli: 'r' }, // Recurse subdirectories. For `-r0` usage see `raw` @TODO doc usage and tech choice - { type: 'bool', api: 'hardlinks', cli: 'snh' }, // Store hard links as links (WIM and TAR formats only) { type: 'bool', api: 'ntSecurity', cli: 'sni' }, // Store NT security + { type: 'bool', api: 'openFiles', cli: 'ssw' }, // Compress files open for writing + { type: 'bool', api: 'recursive', cli: 'r' }, // Recurse subdirectories. For `-r0` usage see `raw` { type: 'bool', api: 'symlinks', cli: 'snl' }, // Store symbolic links as links (WIM and TAR formats only) + { type: 'bool', api: 'techInfo', cli: 'slt' }, // Show technical information + { type: 'bool', api: 'timeStats', cli: 'bt' }, { type: 'bool', api: 'toStdout', cli: 'so' }, // Write data to stdout { type: 'bool', api: 'yes', cli: 'y' }, // Assume Yes on all queries { type: 'boolContext', api: 'alternateStreamStore', cli: 'sns' }, // Store NTFS alternate Streams @@ -38,6 +40,7 @@ export const FLAGS = [ { type: 'stringArray', api: 'method', cli: 'm' }, // Set Compression Method { type: 'stringArray', api: 'outputStreams', cli: 'bs' }, // Set output stream for output/error/progress { type: 'stringArray', api: 'volumes', cli: 'v' } // Create Volumes + // Advanced ] export const OPTIONS_DEFAULT = { @@ -63,3 +66,13 @@ export const COMMAND_LETTERS = { test: 't', update: 'u' } + +// =TU+R.- +export const SYMBOL_OPERATIONS = { + '=': 'renamed', + 'T': 'tested', + 'U': 'updated', + 'R': 'skipped', + '.': 'deleted', + '-': 'extracted' +} diff --git a/test/func/update.spec.js b/test/func/update.spec.js index 94fe920..ba90df1 100644 --- a/test/func/update.spec.js +++ b/test/func/update.spec.js @@ -95,11 +95,11 @@ describe('Functional: update()', function () { let dataAgg = [] seven.on('data', d => dataAgg.push(d)) seven.on('end', function () { - expect(dataAgg).to.deep.include({ symbol: 'R', file: '#0' }) - expect(dataAgg).to.deep.include({ symbol: 'R', file: 'root.md' }) - expect(dataAgg).to.deep.include({ symbol: 'R', file: 'root.not' }) - expect(dataAgg).to.deep.include({ symbol: '.', file: 'root.txt' }) - expect(dataAgg).to.deep.include({ symbol: 'U', file: 'root.txt' }) + expect(dataAgg).to.deep.include({ symbol: 'R', file: '#0', status: 'skipped' }) + expect(dataAgg).to.deep.include({ symbol: 'R', file: 'root.md', status: 'skipped' }) + expect(dataAgg).to.deep.include({ symbol: 'R', file: 'root.not', status: 'skipped' }) + expect(dataAgg).to.deep.include({ symbol: '.', file: 'root.txt', status: 'deleted' }) + expect(dataAgg).to.deep.include({ symbol: 'U', file: 'root.txt', status: 'updated' }) done() }) }) @@ -116,12 +116,11 @@ describe('Functional: update()', function () { let dataAgg = [] seven.on('data', d => dataAgg.push(d)) seven.on('end', function () { - expect(dataAgg).to.deep.include({ symbol: 'R', file: '#0' }) - expect(dataAgg).to.deep.include({ symbol: 'R', file: 'root.not' }) - expect(dataAgg).to.deep.include({ symbol: '.', file: 'root.md' }) - expect(dataAgg).to.deep.include({ symbol: 'U', file: 'root.md' }) - expect(dataAgg).to.deep.include({ symbol: '.', file: 'root.txt' }) - expect(dataAgg).to.deep.include({ symbol: 'U', file: 'root.txt' }) + expect(dataAgg).to.deep.include({ symbol: 'R', file: '#0', status: 'skipped' }) + expect(dataAgg).to.deep.include({ symbol: '.', file: 'root.md', status: 'deleted' }) + expect(dataAgg).to.deep.include({ symbol: 'U', file: 'root.md', status: 'updated' }) + expect(dataAgg).to.deep.include({ symbol: '.', file: 'root.txt', status: 'deleted' }) + expect(dataAgg).to.deep.include({ symbol: 'U', file: 'root.txt', status: 'updated' }) done() }) })