Giter Site home page Giter Site logo

steamer-plugin-example's Introduction

steamer-plugin-example

steamer plugin 例子

完成这个example plugin之后,可以这样使用这个插件:

steamer example -c config.js
// 或
steamer example --config config.js

如何写一个 steamerjs 插件

  • 创建一个函数作为插件
function ExamplePlugin(argv) {
	this.argv = argv;
}

当在终端输入插件命令时,命令的参数将被传入这个函数

更多相关参数的文档,请参考 yargs.

  • init 函数

为插件创建 init prototype 函数, 插件命令在启动时会自动调用此函数。

ExamplePlugin.prototype.init = function() {
	console.log(this.argv);
};

module.exports = ExamplePlugin;
  • help 函数

为插件创建help prototype 函数

ExamplePlugin.prototype.help = function() {
	console.log("Usage of Example: ");
}

当使用命令steamer [plugin name] -h或者steamer [plugin name] --help时,会自动调用 help 函数,用于输出插件帮助文档。

  • 在package.json中指定入口
"main": "index.js"

Util

开发插件时,常常需要一些 Util 函数,帮助你快速开发,Steamer 提供以下 Util 库:

插件的使用

// 将你的插件链接至全局路径,就可以直接使用 `steamer example`
npm link

// 当你完成开发,可以 `unlink` 你的插件
npm unlink

steamer-plugin-example's People

Contributors

lcxfs1991 avatar leoeatle avatar

Watchers

James Cloos avatar  avatar

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.