File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,11 @@ const getPackageManager = () => {
35
35
return 'npm' ;
36
36
} ;
37
37
38
+ const getBinX = pm => {
39
+ if ( pm === 'npm' ) return 'npx' ;
40
+ return pm ;
41
+ } ;
42
+
38
43
const getWorkspaceFlag = pm => {
39
44
if ( pm === 'pnpm' ) {
40
45
return fileExists ( 'pnpm-workspace.yaml' ) ? '-w' : undefined ;
@@ -63,10 +68,14 @@ const main = () => {
63
68
execSync ( cmd , { stdio : 'inherit' } ) ;
64
69
console . info ( '✓ Install Knip' ) ;
65
70
66
- execSync ( 'npm pkg set scripts.knip=knip' , { stdio : 'inherit' } ) ;
67
- console . info ( '✓ Add knip to package.json#scripts' ) ;
68
-
69
- console . info ( `✓ Run "${ bin } run knip" to run knip` ) ;
71
+ try {
72
+ execSync ( 'npm pkg set scripts.knip=knip' , { stdio : 'inherit' } ) ;
73
+ console . info ( '✓ Add knip to package.json#scripts' ) ;
74
+ console . info ( `→ Run "${ bin } run knip" to run knip` ) ;
75
+ } catch {
76
+ console . warn ( '× Failed to add knip to package.json#scripts' ) ;
77
+ console . info ( `→ Run "${ getBinX ( bin ) } knip" to run knip` ) ;
78
+ }
70
79
} ;
71
80
72
81
main ( ) ;
You can’t perform that action at this time.
0 commit comments