initialize-engine

1.2.4 • Public • Published

initialize-engine

NPM version build status Test coverage Downloads js-standard-style

Code generation engine. Inspired by the work in mattdesl/quick-stub.

Installation

$ npm install initialize-engine

Usage

const initializeEngine = require('initialize-engine')
const mkdirp = require('mkdirp')
const path = require('path')
 
initializeEngine({
  pre: [ createDir ],
  files: [
    '.gitignore',
    'LICENSE',
    'README.md',
    'index.js',
    'package.json',
  ],
  devDependencies: [ 'istanbul', 'standard', 'tape' ]
}, { d: '../foobar' })
 
// create specified path
// (obj, fn) -> null
function createDir (argv, next) {
  const loc = path.resolve(path.join(argv.d, argv.name))
  mkdirp(loc, function (err) {
    if (err) return next(err)
    process.chdir(loc)
    argv.directory = loc
    argv.d = loc
    next()
  })
}

API

initializeEngine(opts, argv)

Run the engine with the given opts, and an optional settings object to extend. Opts are run in sequence. The following opts are available:

  • pre: an array of functions that can execucute arbitrary code. Use it to prompt for user input, create repositories, query data and more.
  • files: files to be written. Dotfiles need to be prepended with a _. Files are populated with variables using the {{varName}} syntax.
  • devDependencies: npm dev dependencies to be installed.

License

MIT

Package Sidebar

Install

npm i initialize-engine

Weekly Downloads

13

Version

1.2.4

License

MIT

Last publish

Collaborators

  • mattdesl
  • yoshuawuyts