Skip to content

Commit

Permalink
Output consistency across platforms (#181)
Browse files Browse the repository at this point in the history
* fix: normalize newline

* fix: sort readdir

* fix: correct sorting

* fix: missing npm run in build:registry npm script

* Update apps/www/package.json

Co-authored-by: Sadegh Barati <sadeghbaratiwork@gmail.com>

---------

Co-authored-by: Sadegh Barati <sadeghbaratiwork@gmail.com>
  • Loading branch information
olemarius and sadeghbarati authored Dec 31, 2023
1 parent c2e0523 commit ef3ec54
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions apps/www/scripts/build-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ fs.writeFileSync(path.join(process.cwd(), '__registry__/index.ts'), index)
// ----------------------------------------------------------------------------
// Build registry/styles/[style]/[name].json.
// ----------------------------------------------------------------------------
const newLine = '\n'

for (const style of styles) {
const targetPath = path.join(REGISTRY_PATH, 'styles', style.name)

Expand All @@ -78,11 +80,14 @@ for (const style of styles) {
continue

const files = item.files?.map((file) => {
const content = fs.readFileSync(
let content = fs.readFileSync(
path.join(process.cwd(), 'src/lib/registry', style.name, file),
'utf8',
)

// Replace Windows-style newlines with Unix-style newlines
content = content.replace(/\r\n/g, newLine)

return {
name: basename(file),
content,
Expand All @@ -94,9 +99,11 @@ for (const style of styles) {
files,
}

const payloadStr = JSON.stringify(payload, null, 2).replace(/\r\n/g, newLine)

fs.writeFileSync(
path.join(targetPath, `${item.name}.json`),
JSON.stringify(payload, null, 2),
payloadStr,
'utf8',
)
}
Expand Down
1 change: 1 addition & 0 deletions apps/www/src/lib/registry/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ async function buildUIRegistry(componentPath: string, componentName: string) {

const file_path = join('ui', componentName, dirent.name)
files.push(file_path)
files.sort()

// only grab deps from the vue files
if (dirent.name === 'index.ts')
Expand Down

0 comments on commit ef3ec54

Please sign in to comment.