You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
louisafriederike b00d9f80ed copying eixogen 7 months ago
..
lib copying eixogen 7 months ago
test copying eixogen 7 months ago
test-packages copying eixogen 7 months ago
.jshintrc copying eixogen 7 months ago
.npmignore copying eixogen 7 months ago
.travis.yml copying eixogen 7 months ago
CONTRIBUTING.md copying eixogen 7 months ago
LICENSE.md copying eixogen 7 months ago
README.md copying eixogen 7 months ago
package.json copying eixogen 7 months ago

README.md

package.js

Build Status Coverage Status Codacy Badge NPM Version NPM Downloads

Dependencies Development Dependencies
Donate

Open your node apps for plugin developers

package.js scans the given packageDirectories for your installed application packages and creates an instance by requireing the main JavasScript file if a package.json file was found which contains expected package identifier(s). In the example case let us say {pandaPackage : true}. package.js will pass the packageContstructorSettings to the new required node module.
This implements an easy way to distribute packages akka addons or plugins for node applications via NPM or other package distribution networks.

Installation

npm install package.js --save;

Example usage

var path = require('path');
var events = require('events');
var packageController = require("package.js");

var CustomApp = function  () {
	this.events = new events.EventEmitter();
	return this;
};

var customApp = new CustomApp();

packageController.autoload({
	debug: true,
	identify: function() {
		return (this.meta.pandaPackage === true);
	},
	directories: [path.join(__dirname, "node_modules")],
	packageContstructorSettings: {app:customApp}
});

To identify all application packages the method autoload expects a custom method called identify which is an event and will be executed for each package with the context of the package itself. So far you have access there to the following properties:

  • this.dir - The package directory.
  • this.meta - The package meta data fetched from its package.json.

A package is marked as identified if identify() returns true (boolean).
A detailed demo of usage can be found in the library tests.

Application Packages

Application packages are regular NPM modules and must contain a file called package.json which is normaly used by NPM but maybe with an extra field to identify your application plugins. Here is a very simple hello world example package

Contributing

License

Copyright (c) 2015 Stephan Ahlf stephan.ahlf@gmail.com
This software is dual licensed under MIT and GNU GENERAL PUBLIC LICENSE Version 3.