mirror of
https://github.com/napi-rs/napi-rs.git
synced 2025-12-08 19:56:07 +00:00
fix(cli): extra line break in the tail of dts file (#2255)
This commit is contained in:
parent
1427ddce64
commit
20b9de3ec7
Binary file not shown.
Binary file not shown.
@ -614,7 +614,6 @@ Generated by [AVA](https://avajs.dev).
|
||||
export function xxh128(input: Buffer): bigint␊
|
||||
export function xxh3_64(input: Buffer): bigint␊
|
||||
}␊
|
||||
␊
|
||||
`
|
||||
|
||||
## should process type def with noConstEnum correctly
|
||||
@ -1169,5 +1168,4 @@ Generated by [AVA](https://avajs.dev).
|
||||
export function xxh128(input: Buffer): bigint␊
|
||||
export function xxh3_64(input: Buffer): bigint␊
|
||||
}␊
|
||||
␊
|
||||
`
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -92,39 +92,43 @@ export async function processTypeDef(
|
||||
const groupedDefs = preprocessTypeDef(defs)
|
||||
|
||||
header = header ?? ''
|
||||
let dts = ''
|
||||
|
||||
sortBy(Array.from(groupedDefs), ([namespace]) => namespace).forEach(
|
||||
([namespace, defs]) => {
|
||||
if (namespace === TOP_LEVEL_NAMESPACE) {
|
||||
for (const def of defs) {
|
||||
dts += prettyPrint(def, constEnum, 0) + '\n\n'
|
||||
switch (def.kind) {
|
||||
case TypeDefKind.Const:
|
||||
case TypeDefKind.Enum:
|
||||
case TypeDefKind.StringEnum:
|
||||
case TypeDefKind.Fn:
|
||||
case TypeDefKind.Struct: {
|
||||
exports.push(def.name)
|
||||
if (def.original_name && def.original_name !== def.name) {
|
||||
exports.push(def.original_name)
|
||||
const dts =
|
||||
sortBy(Array.from(groupedDefs), ([namespace]) => namespace)
|
||||
.map(([namespace, defs]) => {
|
||||
if (namespace === TOP_LEVEL_NAMESPACE) {
|
||||
return defs
|
||||
.map((def) => {
|
||||
switch (def.kind) {
|
||||
case TypeDefKind.Const:
|
||||
case TypeDefKind.Enum:
|
||||
case TypeDefKind.StringEnum:
|
||||
case TypeDefKind.Fn:
|
||||
case TypeDefKind.Struct: {
|
||||
exports.push(def.name)
|
||||
if (def.original_name && def.original_name !== def.name) {
|
||||
exports.push(def.original_name)
|
||||
}
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
return prettyPrint(def, constEnum, 0)
|
||||
})
|
||||
.join('\n\n')
|
||||
} else {
|
||||
exports.push(namespace)
|
||||
let declaration = ''
|
||||
declaration += `export declare namespace ${namespace} {\n`
|
||||
for (const def of defs) {
|
||||
declaration += prettyPrint(def, constEnum, 2, true) + '\n'
|
||||
}
|
||||
declaration += '}'
|
||||
return declaration
|
||||
}
|
||||
} else {
|
||||
exports.push(namespace)
|
||||
dts += `export declare namespace ${namespace} {\n`
|
||||
for (const def of defs) {
|
||||
dts += prettyPrint(def, constEnum, 2, true) + '\n'
|
||||
}
|
||||
dts += '}\n\n'
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
.join('\n\n') + '\n'
|
||||
|
||||
if (dts.indexOf('ExternalObject<') > -1) {
|
||||
header += `
|
||||
|
||||
@ -854,5 +854,4 @@ Generated by [AVA](https://avajs.dev).
|
||||
export function xxh128(input: Buffer): bigint␊
|
||||
export function xxh3_64(input: Buffer): bigint␊
|
||||
}␊
|
||||
␊
|
||||
`
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -844,4 +844,3 @@ export declare namespace xxh3 {
|
||||
export function xxh128(input: Buffer): bigint
|
||||
export function xxh3_64(input: Buffer): bigint
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user