-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from blackflux/dev
[Gally]: master <- dev
- Loading branch information
Showing
27 changed files
with
276 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
eslint |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"configs": [ | ||
"jetbrains/exclude-coverage-folder" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"target": ".idea/${projectName}.iml", | ||
"format": "xml", | ||
"strategy": "xml-merge", | ||
"snippets": [ | ||
{ | ||
"name": "exclude-folder-from-module", | ||
"variables": { | ||
"folder": "coverage" | ||
} | ||
} | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
src/configs/jetbrains/snippets/exclude-folder-from-module.iml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<module> | ||
<component> | ||
<content url="file://$MODULE_DIR$"> | ||
<excludeFolder url="file://$MODULE_DIR$/${folder}"/> | ||
</content> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const objectDeepContain = require('object-deep-contain'); | ||
|
||
const mergeRec = (target, changeset) => { | ||
if (changeset === undefined) { | ||
return target; | ||
} | ||
|
||
const isArray = Array.isArray(target); | ||
if (isArray !== Array.isArray(changeset)) { | ||
return changeset; | ||
} | ||
|
||
if (isArray) { | ||
let next = 0; | ||
for (let idx = 0; idx < target.length && next < changeset.length; idx += 1) { | ||
const targetElement = target[idx]; | ||
const toInsert = changeset[next]; | ||
|
||
if (objectDeepContain( | ||
targetElement, | ||
Object | ||
.entries(toInsert) | ||
.reduce((p, [k, v]) => Object.assign(p, k === 'elements' ? {} : { [k]: v }), {}) | ||
)) { | ||
// eslint-disable-next-line no-param-reassign | ||
target[idx] = mergeRec(targetElement, toInsert); | ||
next += 1; | ||
} | ||
} | ||
target.push(...changeset.slice(next)); | ||
return target; | ||
} | ||
|
||
if (target instanceof Object && changeset instanceof Object) { | ||
return [...new Set(Object.keys(target).concat(Object.keys(changeset)))] | ||
.reduce((p, k) => Object.assign(p, { [k]: mergeRec(target[k], changeset[k]) }), {}); | ||
} | ||
|
||
return changeset; | ||
}; | ||
|
||
module.exports = (target, changeset) => Object.assign(target, { data: mergeRec(target.data, changeset.data) }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const expect = require('chai').expect; | ||
const tmp = require('tmp'); | ||
const sfs = require('smart-fs'); | ||
const xmlMerge = require('../../src/util/xml-merge'); | ||
|
||
describe('Integration xml-merge.js', () => { | ||
fs.readdirSync(path.join(__dirname, 'xml-merge')) | ||
.forEach((f) => { | ||
it(`Testing '${f}'`, () => { | ||
const target = sfs.smartRead(path.join(__dirname, 'xml-merge', f, 'target.xml')); | ||
const changeset = sfs.smartRead(path.join(__dirname, 'xml-merge', f, 'changeset.xml')); | ||
const result = sfs.smartRead(path.join(__dirname, 'xml-merge', f, 'result.xml')); | ||
const merged = xmlMerge(target, changeset); | ||
expect(result).to.deep.equal(merged); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Unit xml-merge.js', () => { | ||
let dir; | ||
beforeEach(() => { | ||
dir = tmp.dirSync({ keep: false, unsafeCleanup: true }).name; | ||
}); | ||
|
||
const executeTest = (target, changeset, result) => { | ||
fs.writeFileSync(path.join(dir, 'target.xml'), target); | ||
fs.writeFileSync(path.join(dir, 'changeset.xml'), changeset); | ||
fs.writeFileSync(path.join(dir, 'result.xml'), result); | ||
|
||
const merged = xmlMerge( | ||
sfs.smartRead(path.join(dir, 'target.xml')), | ||
sfs.smartRead(path.join(dir, 'changeset.xml')) | ||
); | ||
expect(merged).to.deep.equal(sfs.smartRead(path.join(dir, 'result.xml'))); | ||
}; | ||
|
||
it('Test Simple Merge', () => { | ||
executeTest('<a/>', '<b/>', '<a/><b/>'); | ||
executeTest('<r><a/></r>', '<r><b/></r>', '<r><a/><b/></r>'); | ||
}); | ||
|
||
it('Test Header Merge', () => { | ||
executeTest( | ||
'<?xml version="1.0" ?>', | ||
'<?xml encoding="UTF-8" ?>', | ||
'<?xml version="1.0" encoding="UTF-8" ?>' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<root> | ||
<b y="4"/> | ||
<a y="5"/> | ||
<b y="6"/> | ||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<root> | ||
<a x="1"/> | ||
<b x="2"/> | ||
<a x="3"/> | ||
<b y="4"/> | ||
<a y="5"/> | ||
<b y="6"/> | ||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<root> | ||
<a x="1"/> | ||
<b x="2"/> | ||
<a x="3"/> | ||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<empty /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml standalone="yes" ?> | ||
<empty /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<module> | ||
<component> | ||
<orderEntry type="B"> | ||
<test/> | ||
</orderEntry> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<module> | ||
<component> | ||
<orderEntry type="A"/> | ||
<orderEntry type="B"> | ||
<test/> | ||
</orderEntry> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<module> | ||
<component> | ||
<orderEntry type="A"/> | ||
<orderEntry type="B"> | ||
<test/> | ||
</orderEntry> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<module> | ||
<component> | ||
<orderEntry type="A"> | ||
<test/> | ||
</orderEntry> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<module> | ||
<component> | ||
<orderEntry type="A"> | ||
<test/> | ||
</orderEntry> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<module> | ||
<component> | ||
<orderEntry type="A"/> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<module> | ||
<component> | ||
<orderEntry type="B"> | ||
<test/> | ||
</orderEntry> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<module> | ||
<component> | ||
<orderEntry type="A"/> | ||
<orderEntry type="B"> | ||
<test/> | ||
</orderEntry> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<module> | ||
<component> | ||
<orderEntry type="A"/> | ||
<orderEntry type="B"/> | ||
</component> | ||
</module> |
Oops, something went wrong.