Coder Social home page Coder Social logo

base-runner's Introduction

base-runner NPM version NPM monthly downloads NPM total downloads Linux Build Status

Orchestrate multiple instances of base at once.

Install

Install with npm:

$ npm install --save base-runner

Usage

var runner = require('base-runner');
var Base = require('base');

runner(Base, options, argv, function(err, app, runnerContext) {
  // `err`: error object, if an error occurred
  // `app`: instance of `base` 
  // `runnerContext`: object with `argv`, `env` and `options` properties
});

Params

  • Base - (required) base constructor
  • options - (required) configuration options
  • argv - (required) parsed process.argv object from minimist or whatever argv parser you prefer.

Example

var runner = require('base-runner');
var Base = require('base');
var config = {
  name: 'awesome',
  cwd: process.cwd(),
  runner: require('./package.json'),
  processTitle: 'awesome',
  moduleName: 'awesome',
  extensions: {
    '.js': null
  }
};

runner(Base, options, argv, function(err, app, runnerContext) {
  // `err`: error object, if an error occurred
  // `app`: instance of `base` 
  // `runnerContext`: object with `argv`, `env` and `options` properties
});

API

Create a runner with the given constructor, liftoff config object, argv object and callback function.

Params

  • Ctor {Function}: Constructor to use, must inherit base.
  • config {Object}: The config object to pass to liftoff.
  • argv {Object}: Argv object, optionally pre-parsed.
  • cb {Function}: Callback function, which exposes err, app (base application instance) and runnerContext
  • returns {Object}

Example

var Base = require('base');
var argv = require('minimist')(process.argv.slice(2));
var config = {
  name: 'foo',
  cwd: process.cwd(),
  extensions: {'.js': null}
};

runner(Base, config, argv, function(err, app, runnerContext) {
  if (err) throw err;
  // do stuff with `app` and `runnerContext`
  process.exit();
});

Events

The following constructor events are emitted:

preInit

Exposes runnerContext as the only paramter.

Base.on('preInit', function(runnerContext) {
});

init

Exposes runnerContext and app (the application instance) as paramters.

Base.on('init', function(runnerContext, app) {
});

postInit

Exposes runnerContext and app (the application instance) as paramters.

Base.on('postInit', function(runnerContext, app) {
});

finished

Exposes runnerContext and app (the application instance) as paramters.

Base.on('finished', function(runnerContext, app) {
});

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Contributors

Commits Contributor
239 jonschlinkert
2 doowb
1 tunnckoCore

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on July 18, 2017.

base-runner's People

Contributors

doowb avatar jonschlinkert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

base-runner's Issues

Huh, TypeError `utils.union` is not a function, when `verb readme` and have `tasks:["readme"]` in config

Easily as 1, 2, 3... hahaha lol.

[charlike@voltaire compose-emitter]$ verb readme
[TypeError: base-runner#runner utils.union is not a function]

The bug is only when you have tasks:readme on local config and run verb readme, otherwise it works.

And that's strange. Because in this repo it can be found in 2 lines. I check that it exist in lazy-cache file, also it exist in deps, so.. can realize what happens. Maybe it is inherited/passed from another place?

edit: Okey it seems it comes from index.js#L102, but in the try block above that line there's no execution of .sortArgs or another method that calls sortArgs which is the one and only place where utils.union is called. Strange.

createEnv

I was attempting to load helpers from my local project by using package.json and was getting an error.

I changed this line from:

var env = createEnv(fp, opts.cwd, opts);

to

var env = createEnv(fp, opts.cwd, new utils.resolver.Resolver.User(opts));

I'm not sure if this is the correct approach or if there should be other options passed in, but it seemed to work locally. (I also had to fix a bug in load-helpers but that's been published).

If this seems correct, I'll make the change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.