@@ -7,7 +7,7 @@ import { cwd } from 'node:process';
77import { readJson , readJsonSync , writeFile , writeJson } from '@tomjs/node' ;
88import chalk from 'chalk' ;
99import chokidar from 'chokidar' ;
10- import { formatCode , getDtsOutputPath , logger } from './utils' ;
10+ import { getDtsOutputPath , logger } from './utils' ;
1111
1212const ROOT = cwd ( ) ;
1313
@@ -107,8 +107,7 @@ async function genNlsDts(keys: string[], opts: CLIOptions) {
107107 const nslKeys = [ ...new Set ( keys ) ] ;
108108 nslKeys . sort ( ) ;
109109
110- nlsCode = /* ts */ `
111- import '@tomjs/vscode';
110+ nlsCode = /* ts */ `import '@tomjs/vscode';
112111
113112declare module '@tomjs/vscode' {
114113 type I18nMessageType = ${ nslKeys . map ( key => `'${ key } '` ) . join ( ' | ' ) || 'undefined' } ;
@@ -122,8 +121,7 @@ declare module '@tomjs/vscode' {
122121 | [message: I18nMessageType, args: Record<string, any>]
123122 ) => string;
124123 }
125- }
126- ` ;
124+ }` ;
127125
128126 await mergeDts ( opts ) ;
129127
@@ -147,12 +145,10 @@ function getCommandDts(pkg: IExtensionManifest, opts: CLIOptions) {
147145 return '' ;
148146 }
149147
150- return /* ts */ `
151- export type BuiltinCommand = ${ builtinType || 'undefined' } ;
148+ return /* ts */ ` export type BuiltinCommand = ${ builtinType || 'undefined' } ;
152149 export type UserCommand = ${ commandType || 'undefined' } ;
153150
154151 export namespace commands {
155-
156152 export function registerCommand( command: UserCommand,
157153 callback: (...args: any[]) => any,
158154 thisArg?: any,
@@ -176,8 +172,7 @@ function getCommandDts(pkg: IExtensionManifest, opts: CLIOptions) {
176172
177173 export interface StatusBarItem {
178174 command?: BuiltinCommand | UserCommand;
179- }
180- ` ;
175+ }` ;
181176}
182177
183178function getViewDts ( pkg : IExtensionManifest ) {
@@ -223,9 +218,7 @@ async function genPackageDts(opts: CLIOptions) {
223218
224219 pkgCode = /* ts */ `
225220declare module 'vscode' {
226- ${ getCommandDts ( pkg , opts ) }
227-
228- ${ getViewDts ( pkg ) }
221+ ${ [ getCommandDts ( pkg , opts ) , getViewDts ( pkg ) ] . filter ( s => s ) . join ( '\n' ) }
229222}
230223` ;
231224
@@ -236,6 +229,5 @@ declare module 'vscode' {
236229
237230async function mergeDts ( opts : CLIOptions ) {
238231 const codes = [ nlsCode , pkgCode ] . filter ( s => s ) ;
239- const code = await formatCode ( codes . join ( '\n\n' ) , opts . cwd ! ) ;
240- await writeFile ( getDtsOutputPath ( opts ) , `// generated by @tomjs/vscode-dev\n${ code } ` ) ;
232+ await writeFile ( getDtsOutputPath ( opts ) , `// generated by @tomjs/vscode-dev\n${ codes . join ( '\n' ) } ` ) ;
241233}
0 commit comments