support platform-specific modules in infer-components command

This commit is contained in:
Artur Girenko 2017-09-28 21:29:37 +02:00
parent fac4825fcf
commit 3b072819b2

View File

@ -845,22 +845,25 @@ useComponent = (name, platform) ->
catch {message} catch {message}
logErr message logErr message
logModuleDifferences = (platform, existingModules, newModules) ->
modules = new Set(existingModules)
diff = new Set(newModules.filter((m) -> !modules.has(m)))
if(diff.size isnt 0)
log "new #{platform} component import found #{Array.from(diff)}"
inferComponents = () -> inferComponents = () ->
requiresByPlatform = buildRequireByPlatformMap() requiresByPlatform = buildRequireByPlatformMap()
allRequires = []
for k,v of requiresByPlatform
allRequires = Array.from(new Set(allRequires.concat(v)))
config = readConfig() # re-natal file config = readConfig() # re-natal file
modules = new Set(config.modules) logModuleDifferences('common', config.modules, requiresByPlatform.common)
difference = new Set(Array.from(allRequires).filter((m) -> !modules.has(m))) config.modules = requiresByPlatform.common
if(difference.size isnt 0)
log "new component import found #{Array.from(difference)}" platforms = Object.keys config.platforms
config.modules = Array.from(allRequires) for platform in platforms
logModuleDifferences(platform, config.platforms[platform].modules, requiresByPlatform[platform])
config.platforms[platform].modules = requiresByPlatform[platform]
writeConfig(config) writeConfig(config)
else
log "no new component was imported, defaulting to #{Array.from(modules)}"
autoRequire = (enabled) -> autoRequire = (enabled) ->
config = readConfig() config = readConfig()