Skip to content

Commit

Permalink
change *file to *filePath in function parameters (#385)
Browse files Browse the repository at this point in the history
* change *file to *filePath

* fix merge issues

---------

Co-authored-by: Darius Jahandarie <[email protected]>
  • Loading branch information
Casheeew and djahandarie authored Dec 19, 2023
1 parent 6b07b1e commit ae2e2db
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions dev/bin/generate-css-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {formatRulesJson, generateRules, getTargets} from '../generate-css-json.j

/** */
function main() {
for (const {cssFile, overridesCssFile, outputPath} of getTargets()) {
const json = formatRulesJson(generateRules(cssFile, overridesCssFile));
for (const {cssFilePath, overridesCssFilePath, outputPath} of getTargets()) {
const json = formatRulesJson(generateRules(cssFilePath, overridesCssFilePath));
fs.writeFileSync(outputPath, json, {encoding: 'utf8'});
}
}
Expand Down
20 changes: 10 additions & 10 deletions dev/generate-css-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ import {fileURLToPath} from 'url';
const dirname = path.dirname(fileURLToPath(import.meta.url));

/**
* @returns {{cssFile: string, overridesCssFile: string, outputPath: string}[]}
* @returns {{cssFilePath: string, overridesCssFilePath: string, outputPath: string}[]}
*/
export function getTargets() {
return [
{
cssFile: path.join(dirname, '..', 'ext/css/structured-content.css'),
overridesCssFile: path.join(dirname, 'data/structured-content-overrides.css'),
cssFilePath: path.join(dirname, '..', 'ext/css/structured-content.css'),
overridesCssFilePath: path.join(dirname, 'data/structured-content-overrides.css'),
outputPath: path.join(dirname, '..', 'ext/data/structured-content-style.json')
},
{
cssFile: path.join(dirname, '..', 'ext/css/display-pronunciation.css'),
overridesCssFile: path.join(dirname, 'data/display-pronunciation-overrides.css'),
cssFilePath: path.join(dirname, '..', 'ext/css/display-pronunciation.css'),
overridesCssFilePath: path.join(dirname, 'data/display-pronunciation-overrides.css'),
outputPath: path.join(dirname, '..', 'ext/data/pronunciation-style.json')
}
];
Expand Down Expand Up @@ -124,14 +124,14 @@ export function formatRulesJson(rules) {

/**
* Generates a CSS ruleset.
* @param {string} cssFile Path to CSS file.
* @param {string} overridesCssFile Path to override CSS file.
* @param {string} cssFilePath
* @param {string} overridesCssFilePath
* @returns {import('css-style-applier').RawStyleData}
* @throws {Error}
*/
export function generateRules(cssFile, overridesCssFile) {
const content1 = fs.readFileSync(cssFile, {encoding: 'utf8'});
const content2 = fs.readFileSync(overridesCssFile, {encoding: 'utf8'});
export function generateRules(cssFilePath, overridesCssFilePath) {
const content1 = fs.readFileSync(cssFilePath, {encoding: 'utf8'});
const content2 = fs.readFileSync(overridesCssFilePath, {encoding: 'utf8'});
const stylesheet1 = /** @type {css.StyleRules} */ (css.parse(content1, {}).stylesheet);
const stylesheet2 = /** @type {css.StyleRules} */ (css.parse(content2, {}).stylesheet);

Expand Down
4 changes: 2 additions & 2 deletions test/css-json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import {formatRulesJson, generateRules, getTargets} from '../dev/generate-css-js
/** */
function main() {
test('css-json', () => {
for (const {cssFile, overridesCssFile, outputPath} of getTargets()) {
for (const {cssFilePath, overridesCssFilePath, outputPath} of getTargets()) {
const actual = fs.readFileSync(outputPath, {encoding: 'utf8'});
const expected = formatRulesJson(generateRules(cssFile, overridesCssFile));
const expected = formatRulesJson(generateRules(cssFilePath, overridesCssFilePath));
expect(actual).toStrictEqual(expected);
}
});
Expand Down

0 comments on commit ae2e2db

Please sign in to comment.