Use prettier
This commit is contained in:
parent
cef6bd975a
commit
be07bb510f
4 changed files with 93 additions and 75 deletions
4
.prettierrc.json
Normal file
4
.prettierrc.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"semi": false,
|
||||
"singleQuote": true
|
||||
}
|
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"devDependencies": {
|
||||
"@types/bun": "^1.1.6"
|
||||
"@types/bun": "^1.1.6",
|
||||
"prettier": "^3.3.3"
|
||||
}
|
||||
}
|
39
src/index.ts
39
src/index.ts
|
@ -43,12 +43,17 @@ function getSourcemap(root: string): Promise<RojoSourcemap> {
|
|||
})
|
||||
}
|
||||
|
||||
function prefixSourcemap(sourcemap: RojoSourcemap, prefix: string): RojoSourcemap {
|
||||
function prefixSourcemap(
|
||||
sourcemap: RojoSourcemap,
|
||||
prefix: string,
|
||||
): RojoSourcemap {
|
||||
return {
|
||||
name: sourcemap.name,
|
||||
className: sourcemap.className,
|
||||
filePaths: sourcemap.filePaths?.map(path => `${prefix}/${path}`),
|
||||
children: sourcemap.children?.map(child => prefixSourcemap(child, prefix)),
|
||||
filePaths: sourcemap.filePaths?.map((path) => `${prefix}/${path}`),
|
||||
children: sourcemap.children?.map((child) =>
|
||||
prefixSourcemap(child, prefix),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,28 +68,33 @@ function mergeSourcemaps(sourcemaps: RojoSourcemap[]): RojoSourcemap {
|
|||
name: '',
|
||||
className: '',
|
||||
filePaths: [],
|
||||
children: []
|
||||
};
|
||||
children: [],
|
||||
}
|
||||
|
||||
for (const sourcemap of sourcemaps) {
|
||||
merged.name = sourcemap.name;
|
||||
merged.className = sourcemap.className;
|
||||
merged.name = sourcemap.name
|
||||
merged.className = sourcemap.className
|
||||
|
||||
if (sourcemap.filePaths) {
|
||||
merged.filePaths = sourcemap.filePaths;
|
||||
merged.filePaths = sourcemap.filePaths
|
||||
}
|
||||
|
||||
for (const child of sourcemap.children ?? []) {
|
||||
const existingChild = merged.children.findIndex(oldChild => oldChild.name === child.name);
|
||||
const existingChild = merged.children.findIndex(
|
||||
(oldChild) => oldChild.name === child.name,
|
||||
)
|
||||
if (existingChild !== -1) {
|
||||
merged.children[existingChild] = mergeSourcemaps([merged.children[existingChild], child]);
|
||||
merged.children[existingChild] = mergeSourcemaps([
|
||||
merged.children[existingChild],
|
||||
child,
|
||||
])
|
||||
} else {
|
||||
merged.children.push(child);
|
||||
merged.children.push(child)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return merged;
|
||||
return merged
|
||||
}
|
||||
|
||||
async function rebuild() {
|
||||
|
@ -93,7 +103,10 @@ async function rebuild() {
|
|||
getPrefixedSourcemap('Core'),
|
||||
])
|
||||
const sourcemap = mergeSourcemaps(sourcemaps)
|
||||
await fs.promises.writeFile('sourcemap.json', JSON.stringify(sourcemap, null, 2))
|
||||
await fs.promises.writeFile(
|
||||
'sourcemap.json',
|
||||
JSON.stringify(sourcemap, null, 2),
|
||||
)
|
||||
}
|
||||
|
||||
for (const root of SOURCE_ROOTS) {
|
||||
|
|
Loading…
Reference in a new issue