Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rekmarks committed Sep 13, 2021
1 parent efd8cd3 commit 0828289
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions development/build/transforms/remove-fenced-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');
const { PassThrough, Transform } = require('stream');
const { BuildTypes } = require('../utils');

const hasOwnProperty = (obj, key) => Reflect.hasOwnProperty(obj, key);
const hasOwnProperty = (obj, key) => Reflect.hasOwnProperty.call(obj, key);

module.exports = {
createRemoveFencedCodeTransform,
Expand Down Expand Up @@ -246,7 +246,7 @@ function removeFencedCode(filePath, typeOfCurrentBuild, fileContent) {
throw new Error(
getInvalidFenceStructureMessage(
filePath,
`A valid fence consists of two fence lines, but the file contains an uneven number of fence lines.`,
`A valid fence consists of two fence lines, but the file contains an uneven number, "${parsedDirectives.length}", of fence lines.`,
),
);
}
Expand Down Expand Up @@ -413,6 +413,13 @@ function getInvalidFencePairMessage(filePath, line, details) {
return `Invalid fence pair in file "${filePath}" due to line "${line}":\n${details}`;
}

/**
* @param {string} filePath - The path to the file that caused the error.
* @param {string} command - The command of the directive with the invalid
* parameters.
* @param {string} details - An explanation of the error.
* @returns The error message.
*/
function getInvalidParamsMessage(filePath, command, details) {
return `Invalid code fence parameters in file "${filePath}" for command "${command}":\n${details}`;
}
2 changes: 1 addition & 1 deletion development/build/transforms/remove-fenced-code.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ describe('build/transforms/remove-fenced-code', () => {
getMinimalFencedCode().concat(addition),
),
).toThrow(
/A valid fence consists of two fence lines, but the file contains an uneven number of fence lines.$/u,
/A valid fence consists of two fence lines, but the file contains an uneven number, "3", of fence lines.$/u,
);
});
});
Expand Down

0 comments on commit 0828289

Please sign in to comment.