📦 init-package-json
JavaScript (or TypeScript) setup script
var init = require('init-package-json')
var path = require('path')
/**
* Path to a PromZard module. If it's not found, one will be provided for you.
*/
var initFile = path.resolve(process.env.HOME, '.npm-init')
var dir = process.cwd()
/**
* Optional extra stuff that gets put into the PromZard module's context.
* In npm, this is the resolved config object. Exposed as `config`:
*/
var configData = { some: 'extra stuff' }
/**
* Any existing `package.json` file is also exposed in the
* module as the `package` object. These vars are also exposed:
* 1. `filename` path to the `package.json` file
* 2. `basename` the tip of the package dir
* 3. `dirname` the parent of the package dir
*/
init (dir, initFile, configData, (err, data) => {
// the data's already been written to {dir}/package.json
// now you can do stuff with it
})
See PromZard for details about what can go in the config.
Command Line Setup and Usage
First, install globally to expose the binary
yarn global add init-package-json
# or with npm
npm i --global init-package-json
Run npm-init
, or alias it to yarn-init
if you’re anything like me.
npm-init
I just didn’t like the idea of using yarn and running npm-init
. Voila!:
echo "alias yarn-init='npm-init'" >> $HOME/.bash_aliases
MIT / ISC © Nicholas Berlette · Original by npm: init-package-json