-
Notifications
You must be signed in to change notification settings - Fork 0
Generator Configuration File Format
Generator is capable of reading configuration files, and passing configuration options on to the plugins it loads. Configuration files can either contain raw JSON, or JavaScript that exports a single JavaScript object (by doing module.exports = { /* config data */ }
. The former must use a .json
file extension and the latter must use a .js
file extension.
The configuration object is a simple JavaScript object. The keys in this object specify what component of the Generator system should receive the configuration data. All configuration data for generator's core is in the core
section. Configuration data for plugins are keyed by the module name of the plugin (defined in the plugin's package.json file).
When a plugin is initialized, it is passed the configuration section matching its module name (or an empty object if there isn't one).
{
"core" : {
"core-option-1" : 7,
"core-option-2" : false
},
"generator-plugin-name-1" : { // name matches module name for plugin
"option-1" : true,
"option-2" : false
},
"generator-plugin-name-2" : {
"option-3" : { "hoo" : "hah" },
"option-4" : 42
}
}
Configuration files are named either .generator.js/.json
or generator.js/.json
. (Having a .
at the beginning of the filename is a convenient way to hide the configuration from general directory listings). Generator looks for config files in the user's home directory ($HOME
on Mac, %USERPROFILE%
on Windows) and in the current working directory.
Note: "Current working directory" refers to the working directory of the Generator Node process, not to the path of the user's current Photoshop document. Therefore, searching at the current working directory is only useful when Generator is launched separately from Photoshop (for development purposes). To configure the built-in instance of Generator (i.e. by end users), the home directory location should be used. (The working directory of the built-in Generator Node process is currently the filesystem root, though this may change in future versions of Photoshop and should not be relied upon.)
If multiple configuration files are found, their contents are merged. Below is the list of precedence for merging, from lowest precedence to highest precedence (where ~/
represents the user's home directory and ./
represents the current working directory):
~/.generator.json
~/.generator.js
~/generator.json
~/generator.js
./.generator.json
./.generator.js
./generator.json
./generator.js
Note that .json
files must contain JSON and .js
files must contain a single JavaScript module.
Click here for Configuration Options
The initial code for this came in as pull request #68