lint fixes and rename
This commit is contained in:
parent
69c21412f1
commit
4a924536f9
4 changed files with 18 additions and 12 deletions
|
@ -9,8 +9,6 @@ import { __addNonEnumProp } from './utils.mjs'
|
|||
export function getPluginName(plugin) {
|
||||
const toCheck = Array.isArray(plugin) ? plugin[0] : plugin
|
||||
return toCheck.name || toCheck.plugin?.name || false
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/////////////////
|
||||
|
@ -362,8 +360,13 @@ PatternConfig.prototype.__resolvePartDependencies = function (depChain) {
|
|||
|
||||
// if the dependency isn't registered, register it
|
||||
if (!this.parts[dot.name]) {
|
||||
// add the part's configuration
|
||||
// add the part's configuration. this will recursively add the part's dependencies to all parts in the chain
|
||||
this.__addPart([dot, ...depChain])
|
||||
} else {
|
||||
// if it's already registered, recursion won't happen, but we still need to add its resolved dependencies to all parts in the chain
|
||||
this.resolvedDependencies[dot.name].forEach((r) => {
|
||||
depChain.forEach((c) => this.__addDependency('resolvedDependencies', c.name, r))
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
|
@ -11,7 +11,7 @@ import { Store } from './store.mjs'
|
|||
import { Hooks } from './hooks.mjs'
|
||||
import { version } from '../data.mjs'
|
||||
import { __loadPatternDefaults } from './config.mjs'
|
||||
import { PatternConfig, getPluginName } from './patternConfig.mjs'
|
||||
import { PatternConfig, getPluginName } from './pattern-config.mjs'
|
||||
import cloneDeep from 'lodash.clonedeep'
|
||||
|
||||
//////////////////////////////////////////////
|
||||
|
@ -814,11 +814,7 @@ Pattern.prototype.__needs = function (partName, set = 0) {
|
|||
// Walk the only parts, checking each one for a match in its dependencies
|
||||
for (const part of only) {
|
||||
if (part === partName) return true
|
||||
if (this.config.resolvedDependencies[part]) {
|
||||
for (const dependency of this.config.resolvedDependencies[part]) {
|
||||
if (dependency === partName) return true
|
||||
}
|
||||
}
|
||||
if (this.config.resolvedDependencies[part]?.indexOf(partName) !== -1) return true
|
||||
}
|
||||
|
||||
return false
|
||||
|
|
|
@ -238,6 +238,10 @@ describe('Pattern', () => {
|
|||
}
|
||||
})
|
||||
|
||||
it(
|
||||
'Pattern.__init() should resolve nested dependencies for multiple parts that depend on the same part'
|
||||
)
|
||||
|
||||
// I am aware this does too much for one unit test, but this is to simplify TDD
|
||||
// we can split it up later
|
||||
it('Pattern.__init() should resolve nested injections', () => {
|
||||
|
|
|
@ -54,11 +54,14 @@ describe('Pattern', () => {
|
|||
name: 'test',
|
||||
draft: ({ part }) => part,
|
||||
}
|
||||
const design = new Design({ parts: [test] })
|
||||
const you = {
|
||||
name: 'you',
|
||||
draft: ({ part }) => part,
|
||||
}
|
||||
const design = new Design({ parts: [test, you] })
|
||||
const pattern = new design({ only: ['you'] })
|
||||
pattern.draft()
|
||||
expect(pattern.setStores[0].logs.debug.length).to.equal(4)
|
||||
expect(pattern.setStores[0].logs.debug[3]).to.equal(
|
||||
expect(pattern.setStores[0].logs.debug).to.include(
|
||||
'Part `test` is not needed. Skipping draft and setting hidden to `true`'
|
||||
)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue