@@ -56,28 +56,44 @@ export async function updatePackageJson(
5656 } ,
5757 } ;
5858
59- const extraFields =
60- input . name === "@cursorless/cursorless-vscode"
61- ? getCursorlessVscodeFields ( input )
62- : { } ;
59+ const isCursorlessVscode = input . name === "@cursorless/cursorless-vscode" ;
6360
64- const extraScripts = isRoot
65- ? { }
66- : {
67- clean : "rm -rf ./out tsconfig.tsbuildinfo" ,
68- } ;
61+ const extraFields = isCursorlessVscode
62+ ? getCursorlessVscodeFields ( input )
63+ : { } ;
6964
7065 return {
7166 ...input ,
7267 name,
7368 license : "MIT" ,
74- scripts : {
75- ...( input . scripts ?? { } ) ,
76- compile : "tsc --build" ,
77- watch : "tsc --build --watch" ,
78- ...extraScripts ,
79- } ,
69+ scripts : getScripts ( input . scripts , isRoot , isCursorlessVscode ) ,
8070 ...exportFields ,
8171 ...extraFields ,
8272 } as PackageJson ;
8373}
74+
75+ function getScripts (
76+ inputScripts : PackageJson . Scripts | undefined ,
77+ isRoot : boolean ,
78+ isCursorlessVscode : boolean ,
79+ ) {
80+ const scripts : PackageJson . Scripts = {
81+ ...( inputScripts ?? { } ) ,
82+ compile : "tsc --build" ,
83+ watch : "tsc --build --watch" ,
84+ } ;
85+
86+ if ( isRoot ) {
87+ return scripts ;
88+ }
89+
90+ const cleanDirs = [ "./out" , "tsconfig.tsbuildinfo" ] ;
91+
92+ if ( isCursorlessVscode ) {
93+ cleanDirs . push ( "./dist" ) ;
94+ }
95+
96+ scripts . clean = `rm -rf ${ cleanDirs . join ( " " ) } ` ;
97+
98+ return scripts ;
99+ }
0 commit comments