Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for a config object with a 'get' function #5

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions default-input.js
Expand Up @@ -167,11 +167,11 @@ if (!package.keywords) {
}

if (!package.author) {
exports.author = config['init.author.name']
exports.author = config.get('init.author.name')
? {
"name" : config['init.author.name'],
"email" : config['init.author.email'],
"url" : config['init.author.url']
"name" : config.get('init.author.name'),
"email" : config.get('init.author.email'),
"url" : config.get('init.author.url')
}
: prompt('author')
}
Expand Down
8 changes: 8 additions & 0 deletions init-package-json.js
Expand Up @@ -17,6 +17,14 @@ var readJson = require('read-package-json')
function init (dir, input, config, cb) {
if (typeof config === 'function')
cb = config, config = {}

// accept either a plain-jane object, or a config object
// with a "get" method.
if (typeof config.get !== 'function') {
var data = config
config = { get: function (k) { return data[k] } }
}

var package = path.resolve(dir, 'package.json')
input = path.resolve(input)
var pkg
Expand Down