1.2.4 • Published 10 years ago

initialize-engine v1.2.4

Weekly downloads
5
License
MIT
Repository
github
Last release
10 years ago

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

1.2.4

10 years ago

1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago