{"action":"created","issue":{"url":"https://api.github.com/repos/mozilla/node-convict/issues/109","labels_url":"https://api.github.com/repos/mozilla/node-convict/issues/109/labels{/name}","comments_url":"https://api.github.com/repos/mozilla/node-convict/issues/109/comments","events_url":"https://api.github.com/repos/mozilla/node-convict/issues/109/events","html_url":"https://github.com/mozilla/node-convict/issues/109","id":128200141,"number":109,"title":"Pass instance to coerce","user":{"login":"voodooattack","id":1285826,"avatar_url":"https://avatars.githubusercontent.com/u/1285826?v=3","gravatar_id":"","url":"https://api.github.com/users/voodooattack","html_url":"https://github.com/voodooattack","followers_url":"https://api.github.com/users/voodooattack/followers","following_url":"https://api.github.com/users/voodooattack/following{/other_user}","gists_url":"https://api.github.com/users/voodooattack/gists{/gist_id}","starred_url":"https://api.github.com/users/voodooattack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voodooattack/subscriptions","organizations_url":"https://api.github.com/users/voodooattack/orgs","repos_url":"https://api.github.com/users/voodooattack/repos","events_url":"https://api.github.com/users/voodooattack/events{/privacy}","received_events_url":"https://api.github.com/users/voodooattack/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-22T17:06:50Z","updated_at":"2016-01-22T18:50:17Z","closed_at":null,"body":"I'm trying to achieve this:\r\n```\r\n    const schema = {\r\n      env: {\r\n        doc: 'The application environment.',\r\n        format: ['production', 'development', 'test'],\r\n        default: 'development',\r\n        env: 'NODE_ENV',\r\n        arg: 'env'\r\n      },\r\n      configPath: {\r\n        doc: 'Path to the configuration files.',\r\n        env: 'NP_CONFIG_PATH',\r\n        arg: 'config-path',\r\n        format: 'path',\r\n        default: '${local}/config'\r\n      },\r\n      include: {\r\n        doc: 'Any other paths to include.\\n' +\r\n        'placeholders: (case sensitive)\\n' +\r\n        '  ${env} the NODE_ENV variable or the node-env argument.\\n' +\r\n        '  ${configPath} is the path to the configuration files.\\n' +\r\n        '  ${root} is the root path to this NodePress installation.\\n' +\r\n        '  ${local} is the path to the local directory of this NodePress installation.\\n'\r\n        ,\r\n        env: 'NP_CONFIG',\r\n        arg: 'config',\r\n        format: Array,\r\n        default: ['${configPath}/${env}.json']\r\n      },\r\n      ....\r\n```\r\n\r\nThe 'path' custom format looks like this:\r\n\r\n```\r\n    convict.addFormat({\r\n      name: 'path',\r\n      validate() {\r\n      },\r\n      coerce: function(val) {\r\n        console.log(this);\r\n        return val.replace(/\\$\\{(\\w+)}/g, (v,m) => this.get(m));\r\n      }\r\n    });\r\n```\r\n\r\nThis doesn't work inside coerce because it gets passed the format object itself instead of the config object. \r\n\r\nIs there a workaround?"},"comment":{"url":"https://api.github.com/repos/mozilla/node-convict/issues/comments/174009721","html_url":"https://github.com/mozilla/node-convict/issues/109#issuecomment-174009721","issue_url":"https://api.github.com/repos/mozilla/node-convict/issues/109","id":174009721,"user":{"login":"voodooattack","id":1285826,"avatar_url":"https://avatars.githubusercontent.com/u/1285826?v=3","gravatar_id":"","url":"https://api.github.com/users/voodooattack","html_url":"https://github.com/voodooattack","followers_url":"https://api.github.com/users/voodooattack/followers","following_url":"https://api.github.com/users/voodooattack/following{/other_user}","gists_url":"https://api.github.com/users/voodooattack/gists{/gist_id}","starred_url":"https://api.github.com/users/voodooattack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voodooattack/subscriptions","organizations_url":"https://api.github.com/users/voodooattack/orgs","repos_url":"https://api.github.com/users/voodooattack/repos","events_url":"https://api.github.com/users/voodooattack/events{/privacy}","received_events_url":"https://api.github.com/users/voodooattack/received_events","type":"User","site_admin":false},"created_at":"2016-01-22T18:50:16Z","updated_at":"2016-01-22T18:50:16Z","body":"Pull request submitted. :+1: "}}