fix: Formatting issue

This commit is contained in:
Sidharth Vinod 2022-09-08 21:51:42 +05:30
parent 9acf63f7d6
commit 2826bf6823
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
1 changed files with 19 additions and 14 deletions

View File

@ -54,6 +54,15 @@ const WARN_DOCSDIR_DOESNT_MATCH = `Changed files were transformed in ${SOURCE_DO
const verifyOnly: boolean = process.argv.includes('--verify');
const git: boolean = process.argv.includes('--git');
// TODO: Read from .prettierrc?
const prettierConfig: prettier.Config = {
useTabs: false,
tabWidth: 2,
endOfLine: 'auto',
printWidth: 100,
singleQuote: true,
};
let filesWereTransformed = false;
/**
@ -151,19 +160,11 @@ const transformMarkdown = (file: string) => {
// Add the AUTOGENERATED_TEXT to the start of the file
const transformed = `${AUTOGENERATED_TEXT}\n${remark.stringify(out)}`;
copyTransformedContents(
file,
!verifyOnly,
prettier.format(transformed, {
parser: 'markdown',
useTabs: false,
tabWidth: 2,
endOfLine: 'auto',
printWidth: 100,
singleQuote: true,
})
);
const formatted = prettier.format(transformed, {
parser: 'markdown',
...prettierConfig,
});
copyTransformedContents(file, !verifyOnly, formatted);
};
/**
@ -194,7 +195,11 @@ const transformHtml = (filename: string) => {
};
const transformedHTML = insertAutoGeneratedComment(filename);
copyTransformedContents(filename, !verifyOnly, transformedHTML);
const formattedHTML = prettier.format(transformedHTML, {
parser: 'html',
...prettierConfig,
});
copyTransformedContents(filename, !verifyOnly, formattedHTML);
};
/** Main method (entry point) */