From 6596018872cf9ec9caf71166d79099c271429851 Mon Sep 17 00:00:00 2001 From: ecmel Date: Thu, 2 Mar 2023 14:34:24 +0300 Subject: [PATCH] fixes #33 --- index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index a2bdb47..5180b8e 100644 --- a/index.js +++ b/index.js @@ -51,9 +51,16 @@ function parseLocals({options, node}, optionLocals, attributeLocals) { * @param {String} href [node's href attribute value] * @return {Promise} [Promise with file content's] */ -function readFile(options, href) { +function readFile(options, href, tree) { const filePath = path.join(path.isAbsolute(href) ? options.root : path.dirname(options.from), href); + if (tree.messages) { + tree.messages.push({ + type: 'dependency', + file: filePath + }); + } + return new Promise((resolve, reject) => { fs.readFile(filePath, 'utf8', (error, response) => error ? reject(error) : resolve(response)); }); @@ -69,7 +76,7 @@ function parse(options) { tree.match(match(`${options.tag}[${options.attribute}]`), node => { promises.push( - () => readFile(options, node.attrs[options.attribute]) + () => readFile(options, node.attrs[options.attribute], tree) .then(processNodeContentWithPosthtml(node, options)) .then(tree => { // Recursively call parse with node's content tree return parse(Object.assign({}, options, {