Skip to content

Commit

Permalink
[DO NOT MERGE] Test
Browse files Browse the repository at this point in the history
  • Loading branch information
domoscargin committed Aug 3, 2023
1 parent 1a78268 commit 3ce997f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/scripts/comments.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readFile } from 'node:fs/promises'

import { filesize } from 'filesize'
// import { filesize } from 'filesize'
import { getFileSizes, getStats, modulePaths } from 'govuk-frontend-stats'

/**
Expand Down Expand Up @@ -93,15 +93,15 @@ export async function commentStats (
const reviewAppURL = getReviewAppUrl(issueNumber)

// File sizes
const fileSizeTitle = '### File sizes'
// const fileSizeTitle = '### File sizes'
const fileSizes = await getFileSizes()
const fileSizeRows = Object.entries(fileSizes)
/* const fileSizeRows = Object.entries(fileSizes)
.map(([key, value]) => {
return [`[${key}](https://github.com/alphagov/govuk-frontend/blob/${githubActionContext.commit}/${key})`, filesize(value.size, { base: 2 })]
})
const fileSizeHeaders = ['File', 'Size']
const fileSizeTable = renderTable(fileSizeHeaders, fileSizeRows)
const fileSizeText = [fileSizeTitle, fileSizeTable].join('\n')
const fileSizeText = [fileSizeTitle, fileSizeTable].join('\n') */

// Modules
const modulesTitle = '### Modules'
Expand Down Expand Up @@ -129,7 +129,7 @@ export async function commentStats (
{
markerText,
titleText,
bodyText: [fileSizeText, modulesText].join('\n')
bodyText: [JSON.stringify(fileSizes), modulesText].join('\n')
}
)
}
Expand Down
7 changes: 4 additions & 3 deletions shared/stats/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ export async function getStats (modulePath) {
/**
* Returns file sizes of key files
*
* @returns {Promise<{[key: string]: Promise<import('fs').Stats>}>} - File names and size
* @returns {Promise<{[key: string]: import('fs').Stats}>} - File names and size
*/
export async function getFileSizes () {
/** @type { { [key: string]: Promise<import('fs').Stats> } } */
/** @type { { [key: string]: import('fs').Stats } } */
const result = {}

for (const filename of filesForAnalysis) {
result[filename] = stat(join(paths.root, filename))
const stats = await stat(join(paths.root, filename))
result[filename] = stats
}

return result
Expand Down

0 comments on commit 3ce997f

Please sign in to comment.