Skip to content

Commit

Permalink
Update build-tokens.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
alizedebray committed Nov 5, 2024
1 parent 3fa6537 commit 2dcda22
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions .github/workflows/build-tokens.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,28 @@ jobs:
'theme.scss',
'components.scss',
]
const outputFileNames = fs.readdirSync('packages/tokens/dist')
const outputFiles = outputFileNames
.map(fileName => ({
type: path.extname(fileName).replace(/^\./, ''),
name: fileName,
content: fs.readFileSync(`packages/tokens/dist/${fileName}`, 'utf8')
}))
.map(({ type, name, content }) => {
if (type === 'scss') content = content.replaceAll('\n\n', '\n \n').replaceAll('$', '$').replaceAll(' ', '  ')
return { type, name, content }
})
.sort((a, b) => (outputOrder.includes(a.name) ? outputOrder.indexOf(a.name) : 1000) - (outputOrder.includes(b.name) ? outputOrder.indexOf(b.name) : 1000))
const outputFileAndDirNames = fs.readdirSync('packages/tokens/dist')
const outputDirNames = outputFileAndDirNames.filter(fileOrDir => fs.lstatSync(`packages/tokens/dist/${fileOrDir}`).isDirectory())
const outputFileNames = outputFileAndDirNames.filter(fileOrDir => fs.lstatSync(`packages/tokens/dist/${fileOrDir}`).isFile())
const getFiles = (fileNames, dirName) => {
const dirPath = dirName ? `${dirName}/` : ''
return fileNames
.map(fileName => ({
type: path.extname(fileName).replace(/^\./, ''),
name: fileName,
content: fs.readFileSync(`packages/tokens/dist/${dirPath}${fileName}`, 'utf8')
}))
.map(({ type, name, content }) => {
if (type === 'scss') content = content.replaceAll('\n\n', '\n \n').replaceAll('$', '$').replaceAll(' ', '  ')
return { type, name, content }
})
.sort((a, b) => (outputOrder.includes(a.name) ? outputOrder.indexOf(a.name) : 1000) - (outputOrder.includes(b.name) ? outputOrder.indexOf(b.name) : 1000))
}
const outputFiles = [
...outputDirNames.flatMap(dirName => getFiles(readdirSync(`dist/${dirName}`), dirName),
...getFiles(outputFileNames)
]
return `# Token Build
## Input
Expand Down

0 comments on commit 2dcda22

Please sign in to comment.