From 87757eabb6bb35b0a90062fc1d64f549612f8aa3 Mon Sep 17 00:00:00 2001 From: Sebastien Colladon Date: Sat, 27 Mar 2021 21:46:35 +0100 Subject: [PATCH] Deal with added files the same as modified ones Remove not used anymore _fillPackageFromFile Change the API _handleInFile => _handleInDiff (more accurate) --- src/service/inFileHandler.js | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/service/inFileHandler.js b/src/service/inFileHandler.js index e76378ab..c3474d9f 100644 --- a/src/service/inFileHandler.js +++ b/src/service/inFileHandler.js @@ -37,16 +37,17 @@ class InFileHandler extends StandardHandler { handleAddition() { super.handleAddition() - this._fillPackageFromFile(this.diffs.package) + const toAdd = this._handleInDiff() + this._handleFileWriting(toAdd) } handleDeletion() { - this._handleInFile() + this._handleInDiff() } handleModification() { super.handleAddition() - const toAdd = this._handleInFile() + const toAdd = this._handleInDiff() this._handleFileWriting(toAdd) } @@ -70,7 +71,7 @@ class InFileHandler extends StandardHandler { fse.outputFileSync(path.join(this.config.output, this.line), xmlContent) } - _handleInFile() { + _handleInDiff() { const diffContent = fileGitDiff(this.line, this.config), toRemove = {}, toAdd = {} @@ -135,24 +136,6 @@ class InFileHandler extends StandardHandler { } } - _fillPackageFromFile(packageObject) { - const result = this._parseFile() - const metadataContent = Object.values(result.fileContent)[0] - - result.authorizedKeys.forEach(subType => { - const meta = Array.isArray(metadataContent[subType]) - ? metadataContent[subType] - : [metadataContent[subType]] - meta.forEach(value => - this._fillPackageFromDiff( - packageObject, - `${this.parentMetadata.directoryName}.${subType}`, - value.fullName - ) - ) - }) - } - _fillPackageFromDiff(packageObject, subType, value) { const elementFullName = `${ (subType !== mc.LABEL_DIRECTORY_NAME