-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #433 from lawgsy/feature/settings-on-initialize
Pass 'settings' object to plugins on initalize() and initializeAsync()
- Loading branch information
Showing
6 changed files
with
24 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
import config from 'lib/config' | ||
import plugins from 'plugins' | ||
|
||
export default pluginName => config.get('plugins')[pluginName] || {} | ||
const getSettings = pluginName => config.get('plugins')[pluginName] || {} | ||
|
||
const getUserSettings = (pluginName) => { | ||
const settings = getSettings(pluginName) | ||
if (plugins[pluginName].settings) { | ||
// Provide default values if nothing is set by user | ||
Object.keys(plugins[pluginName].settings).forEach((key) => { | ||
settings[key] = settings[key] || plugins[pluginName].settings[key].defaultValue | ||
}) | ||
} | ||
return settings | ||
} | ||
|
||
export default getUserSettings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import get from './get' | ||
import getUserSettings from './get' | ||
import validate from './validate' | ||
|
||
export default { get, validate } | ||
export default { getUserSettings, validate } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters