Main
Packhouse Main
Main是一個靜態方法,主要是基於管理的語法糖,使用方法如下:
const Order = require('packhouse/plugins/order')
const Packhouse = require('packhouse')
let main = Packhouse.Main((packhouse, event) => {
    // 可以傳遞參數
    console.log(event.hello) // world
    // 可以定義事件
    packhouse.on('run', () => { ... })
    // 回傳基本資料
    return {
        plugins: [
            Order
        ],
        groups: {
            'math': () => {
                return {
                    data: require('./math'),
                    options: {}
                }
            }
        },
        mergers: {
            'myMerger': () => {
                return {
                    data: require('./myMerger'),
                    options: {}
                }
            }
        }
    }
})
let packhouse = main({
    hello: 'world'
})
packhouse.tool('math/sum').action(...)TypeScript
如果你使用TypeScript,可以使用我們提供的Declaration File:
import { Main } from 'packhouse/types'
const Main: Main = Packhouse.Main
const main = Main(() => ({})
const packhouse = main()Last updated
Was this helpful?