1
1
#! /usr/bin/env node
2
2
import { fileURLToPath } from 'node:url'
3
+ import process from 'node:process'
3
4
import { $ , argv , chalk , fs , glob , path } from 'zx'
4
5
import { select } from '@inquirer/prompts'
5
6
7
+ if ( argv . _ [ 0 ] !== 'sg' ) {
8
+ console . log ( chalk . red ( 'Do you want to use `sg` cmd?' ) )
9
+ process . exit ( )
10
+ }
11
+
6
12
$ . verbose = false
7
13
8
14
const __filename = fileURLToPath ( import . meta. url )
@@ -34,9 +40,9 @@ if (macro === 'jsx-directive') {
34
40
} )
35
41
}
36
42
37
- const defineShortSlots = 'define-slots'
43
+ let defineSlots = 'define-slots'
38
44
if ( [ 'jsx-directive' , 'setup-sfc' ] . includes ( macro ) ) {
39
- render = await select ( {
45
+ defineSlots = await select ( {
40
46
message : chalk . green (
41
47
`Which define-slots macro do you want to use?` ,
42
48
) ,
@@ -60,7 +66,7 @@ if (macro === 'short-v-model') {
60
66
} )
61
67
}
62
68
63
- const targetDirectory = path . resolve ( argv . _ [ 0 ] || '.' )
69
+ const targetDirectory = path . resolve ( argv . _ . at ( - 1 ) || '.' )
64
70
65
71
const files = await glob ( `${ targetDirectory } /**/*.vue` , {
66
72
ignore : [
@@ -82,7 +88,7 @@ if (['jsx-directive', 'setup-sfc'].includes(macro)) {
82
88
83
89
await $ `${ sg } scan -c ${ config } -U --filter '^tsx v-' ${ targetDirectory } `
84
90
85
- if ( defineShortSlots )
91
+ if ( defineSlots === 'define-short-slots' )
86
92
await $ `${ sg } scan -c ${ config } -U --filter 'tsx define-short-slots' ${ targetDirectory } `
87
93
88
94
if ( macro === 'setup-sfc' ) {
0 commit comments