init-package-json icon indicating copy to clipboard operation
init-package-json copied to clipboard

Trying to provide default option values

Open jhyland87 opened this issue 9 years ago • 2 comments

My code example (below) is pretty much exactly what was taken from the README file, just with less comments and the configData populated differently.

I thought that passing an object to the 3rd parameter of the init method would provide it with default options, but I guess thats not the case?

var init = require('init-package-json')
var path = require('path')

var initFile = path.resolve(process.env.HOME, '.npm-init')

var dir = process.cwd()

// Desired default settings/options
var configData = { 
    name: 'Default Name..',
    description: 'Default description..',
    some: 'extra stuff' // What is this one even suppose to do then?..
}

init(dir, initFile, configData, ( er, data ) => {
    console.log('Result:', err || data)
})

Is there a way to provide default options? Short of creating the package.json manually

Thanks

jhyland87 avatar Jan 04 '16 16:01 jhyland87

See: https://docs.npmjs.com/misc/config#init-module. Note that I've filed this as well. https://github.com/npm/npm/issues/11137 cc @isaacs.

kevinSuttle avatar Jan 13 '16 17:01 kevinSuttle

How we can pass some custom parameters so ?

JordanMachado avatar Mar 22 '17 17:03 JordanMachado