/workspace/cache
The module exports the default checkWorkspaceCache method which returns the async cacheWorkspace method which resolves into a JSON workspace.
Default templates can be overwritten in the workspace or by providing a CUSTOM_TEMPLATES xyzEnvironment variable which references a JSON with templates to be merged into the workspace.
- Source
Requires
- module:/provider/getSrc
- module:/utils/merge
- module:/utils/processEnv
Methods
(inner) assign_workspace_templates(workspace_templates, templates_object, typeopt) → {Object}
The method assigns objects in a templates object to the workspace.templates provided as workspace_templates param.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
workspace_templates | object | The workspace.templates object. | ||
templates_object | Object | An object of templates to be assigned with the template key to the workspace templates. | ||
type | string | <optional> | 'core' | The type value to assign to the template to identify the origin. |
- Source
templates_object with _core: true property.
- Type:
- Object
(async, inner) cacheWorkspace() → {Promise.<workspace>}
The workspace is retrived from the source defined in the WORKSPACE xyzEnvironment variable.
Templates defined in the CUSTOM_TEMPLATES xyzEnvironment variable are spread into the default workspace.templates{}.
Each locale from the workspace.locale{} is merged into the workspace.locale{} template.
Locale objects get their key and name properties assigned if falsy.
The workspace is assigned to the module scope workspacePromise variable and the timestamp is recorded.
- Source
Resolves to the JSON workspace.
- Type:
- Promise.<workspace>
(inner) checkWorkspaceCache(forceopt) → {Promise.<workspace>}
The async cacheWorkspace method is assigned to the module scope workspacePromise variable. The variable is re-assigned if the WORKSPACE_AGE xyzEnvironment variable is exceeded or the force param is true.
| Name | Type | Attributes | Description |
|---|---|---|---|
force | boolean | <optional> | The workspace cache will be cleared with the force param flag. |
- Source
Resolves to the JSON workspace.
- Type:
- Promise.<workspace>