Skip to content

Commit

Permalink
fix: cleanup messages between files (tree.messages)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-ciniawsky committed Jan 16, 2018
1 parent 8487a35 commit dc391c1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
25 changes: 1 addition & 24 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,7 @@ var api = {

return node
})
},
/**
* Tree messages to store and pass metadata between plugins
*
* @memberof tree
* @type {Array} messages
*
* @example
* ```js
* export default function plugin (options = {}) {
* return function (tree) {
* tree.messages.push({
* type: 'dependency',
* file: 'path/to/dependency.html',
* from: tree.options.from
* })
*
* return tree
* }
* }
* ```
*/
messages: []
}
}

/**
Expand All @@ -124,7 +102,6 @@ var api = {
module.exports = function (tree) {
tree.walk = api.walk
tree.match = api.match
tree.messages = api.messages
}

module.exports.walk = api.walk
Expand Down
28 changes: 27 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,32 @@ PostHTML.prototype.process = function (tree, options) {
: parser(tree, options)

tree.options = options

/**
* Messages to store and pass metadata
*
* @memberof tree
*
* @type {Array} messages
*
* @example
* ```js
* module.exports = function plugin (options = {}) {
* return function (tree) {
* const message = {
* type: 'dependency',
* file: 'path/to/dependency.html',
* from: tree.options.from
* }
*
* tree.messages.push(message)
*
* return tree
* }
* }
* ```
*/
tree.messages = []
tree.processor = this

// sync mode
Expand Down Expand Up @@ -227,7 +253,7 @@ function tryCatch (tryFn, catchFn) {
}
}

/**
/**
* Wraps the PostHTMLTree within an object using a getter to render HTML on demand.
*
* @private
Expand Down

0 comments on commit dc391c1

Please sign in to comment.