1.0.0 • Published 5 years ago

@mutantlove/pluginus v1.0.0

Weekly downloads
3
License
BSD-3-Clause
Repository
github
Last release
5 years ago

CircleCI npm package version Coverage Status

pluginus

Dependency injection with promise support - Things that get ran after other things.

Install

npm install @mutantlove/pluginus

Use

plugins/thing.js

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

plugins/second-thing.js

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

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

index.js

import glob from "glob"
import { pluginus } from "@mutantlove/pluginus"

pluginus({
  files: glob.sync("./plugins/*.js", { absolute: true }),
}).then(({ Thing, SecondThing }) => {
  // Thing
  // => {
  //   foo: "bar",
  // }
  // SecondThing
  // => {
  //   ThingContent: "ipsum bar",
  // }
})

Develop

git clone git@github.com:mutantlove/pluginus.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

Commit Message Format

Using Angular's conventions.

<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing or correcting existing tests
  • chore: Changes to the build process or auxiliary tools and libraries such as documentation generation

Changelog

See the releases section for details.