Skip to content

Commit

Permalink
feat: bundle package
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Sep 1, 2019
1 parent 791542b commit 53a2a0e
Show file tree
Hide file tree
Showing 6 changed files with 2,170 additions and 32 deletions.
13 changes: 13 additions & 0 deletions .babelrc
@@ -0,0 +1,13 @@
{
"env": {
"test": {
"presets": [
["@babel/preset-env", {
"targets": {
"node": "current"
}
}]
]
}
}
}
32 changes: 18 additions & 14 deletions package.json
Expand Up @@ -2,31 +2,35 @@
"name": "hable",
"version": "2.3.0",
"description": "Awaitable hooks for Node.js",
"keywords": [
"hook",
"hookable",
"plugin",
"tapable",
"tappable"
],
"repository": "jsless/hable",
"license": "MIT",
"contributors": [
"Sebastien Chopin (@Atinux)",
"Clark Du (@clarkdo)",
"Pooya Parsa (@pi0)"
],
"repository": "jsless/hable",
"keywords": [
"tapable",
"tappable",
"hook",
"plugin",
"hookable"
],
"main": "lib/hookable.js",
"files": [
"lib"
"src",
"dist"
],
"main": "dist/hable.js",
"browser": "dist/hable.umd.js",
"scripts": {
"test": "yarn lint && yarn jest",
"lint": "eslint lib",
"prepublish": "yarn test",
"release": "standard-version && git push --follow-tags && npm publish"
"build": "bili --module-name hable --minify --format cjs,umd,es src/hable.js",
"lint": "eslint src",
"prepublish": "yarn build && yarn test",
"release": "standard-version && git push --follow-tags && npm publish",
"test": "yarn lint && yarn jest"
},
"devDependencies": {
"bili": "^4.8.1",
"codecov": "^3.0.0",
"eslint": "^5.13.0",
"eslint-config-standard": "^12.0.0",
Expand Down
4 changes: 2 additions & 2 deletions lib/hookable.js → src/hable.js
@@ -1,6 +1,6 @@
const { serial, flatHooks } = require('./utils')
import { serial, flatHooks } from './utils'

module.exports = class Hookable {
export default class Hookable {
constructor (logger = console) {
this._logger = logger
this._hooks = {}
Expand Down
4 changes: 2 additions & 2 deletions lib/utils.js → src/utils.js
@@ -1,4 +1,4 @@
exports.flatHooks = function flatHooks (configHooks, hooks = {}, parentName) {
export function flatHooks (configHooks, hooks = {}, parentName) {
for (const key in configHooks) {
const subHook = configHooks[key]
const name = parentName ? `${parentName}:${key}` : key
Expand All @@ -11,6 +11,6 @@ exports.flatHooks = function flatHooks (configHooks, hooks = {}, parentName) {
return hooks
}

exports.serial = function serial (tasks, fn) {
export function serial (tasks, fn) {
return tasks.reduce((promise, task) => promise.then(previous => fn(task, previous)), Promise.resolve(null))
}
2 changes: 1 addition & 1 deletion test/hookable.test.js
@@ -1,5 +1,5 @@
const Hookable = require('..')
const { flatHooks } = require('../lib/utils')
const { flatHooks } = require('../src/utils')

describe('core: hookable', () => {
beforeEach(() => {
Expand Down

0 comments on commit 53a2a0e

Please sign in to comment.