Reformated/commented for clarity

This commit is contained in:
airjp73 2018-02-06 11:21:33 -05:00
parent 6dce24cc53
commit ce342d528a

View File

@ -42,29 +42,32 @@ if (typeof storeData !== 'function') {
continue continue
} }
//if file is user/index.js //if file is foo/index.js
//it should save as user //it should save as foo
var isIndex = (name === 'index') let isIndex = (name === 'index')
if (isIndex) if (isIndex)
namePath.pop() namePath.pop()
let module = getModuleNamespace(storeData, namePath) let module = getModuleNamespace(storeData, namePath)
let fileModule = getModule(filename)
name = namePath.pop() name = namePath.pop()
module[name] = module[name] || {} module[name] = module[name] || {}
var fileModule = getModule(filename)
//if file is foo.js, existing properties take priority
//because it's the least specific case
if (!isIndex) { if (!isIndex) {
module[name] = Object.assign({}, fileModule, module[name]) module[name] = Object.assign({}, fileModule, module[name])
module[name].namespaced = true module[name].namespaced = true
continue continue
} }
//if file is foo/index.js we want to overwrite properties from foo.js
//but not from appended mods like foo/actions.js
var appendedMods = [] var appendedMods = []
if (module[name].appends) { if (module[name].appends) {
fileModule.appends = module[name].appends fileModule.appends = module[name].appends
for (let append of module[name].appends) { for (let append of module[name].appends)
appendedMods[append] = module[name][append] appendedMods[append] = module[name][append]
}
} }
module[name] = Object.assign(module[name], fileModule, appendedMods) module[name] = Object.assign(module[name], fileModule, appendedMods)
} }