Skip to content

Commit

Permalink
remove assignDefaults
Browse files Browse the repository at this point in the history
  • Loading branch information
dbauszus-glx committed Oct 20, 2023
1 parent e9f1bad commit e5ace68
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 42 deletions.
40 changes: 0 additions & 40 deletions mod/workspace/assignDefaults.js

This file was deleted.

37 changes: 35 additions & 2 deletions mod/workspace/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const getFrom = {
'mongodb': ref => mongodb(ref.split(/:(.*)/s)[1])
}

const assignDefaults = require('./assignDefaults')
const merge = require('../utils/merge')

process.env.WORKSPACE_AGE ??= 3600000

Expand Down Expand Up @@ -111,7 +111,40 @@ async function cache() {
...workspace.templates
}

await assignDefaults(workspace)
workspace.locale ??= {
layers: {}
}

workspace.locales ??= {
locale: workspace.locale
}

// Loop through locale keys in workspace.
Object.keys(workspace.locales).forEach(locale_key => {

// Get locale object from key.
const locale = workspace.locales[locale_key]

// A default locale has been defined in the workspace.
if (typeof workspace.locale === 'object') {

// Merge the workspace template into workspace.
merge(locale, workspace.locale)
}

// A template exists for the locale key.
if (Object.hasOwn(workspace.templates, locale_key) && typeof workspace.templates[locale_key] === 'object') {

// Merge the workspace template into workspace.
merge(locale, workspace.templates[locale_key])
}

// Assign key value as key on locale object.
locale.key = locale_key

// Assign locale key as name with no existing name on locale object.
locale.name = locale.name || locale_key
})

if (workspace.plugins) {

Expand Down

0 comments on commit e5ace68

Please sign in to comment.