/pluginus.xyz

Dependency injection with promise support. Things get ran after others finish.

Primary LanguageJavaScriptMIT LicenseMIT

CircleCI npm version dev-badge Coverage Status

pluginus

Install

npm install pluginus.xyz

Use

plugin-1.js

exports default {
  create: () =>
    new Promise(resolve => {
      setTimeout(() => {
        resolve({
          foo: "bar",
        })
      }, 50)
    }),
}

plugin-2.js

module.exports = {
  // First "Plugin1" is resolved to { foo: "bar" }
  depend: ["Plugin1"],

  // After dependencies are resolved, the current constructor is called
  create: Plugin1 => ({
    lorem: `ipsum ${Plugin1.foo}`,
  }),
}

index.js

import { pluginus } from "pluginus.xyz"

pluginus({
  files: ["path-to-plugin1", "path-to-plugin2"],
}).then(({ Plugin1, Plugin2 }) => {
  // Plugin1
  // => {
  //   foo: "bar",
  // }
  //
  // Plugin2
  // => {
  //   lorem: "ipsum bar",
  // }
})

Develop

git clone git@github.com:andreidmt/pluginus.xyz.git && \
  cd pluginus && \
  npm run setup

Run all *.test.js in src folder

npm test

Watch src and examples folder for changes and re-run tests

npm run tdd

Changelog

See the releases section for details.