11#! /usr/bin/env node
22import { fileURLToPath } from 'node:url'
3+ import process from 'node:process'
34import { $ , argv , chalk , fs , glob , path } from 'zx'
45import { select } from '@inquirer/prompts'
56
7+ if ( argv . _ [ 0 ] !== 'sg' ) {
8+ console . log ( chalk . red ( 'Do you want to use `sg` cmd?' ) )
9+ process . exit ( )
10+ }
11+
612$ . verbose = false
713
814const __filename = fileURLToPath ( import . meta. url )
@@ -34,9 +40,9 @@ if (macro === 'jsx-directive') {
3440 } )
3541}
3642
37- const defineShortSlots = 'define-slots'
43+ let defineSlots = 'define-slots'
3844if ( [ 'jsx-directive' , 'setup-sfc' ] . includes ( macro ) ) {
39- render = await select ( {
45+ defineSlots = await select ( {
4046 message : chalk . green (
4147 `Which define-slots macro do you want to use?` ,
4248 ) ,
@@ -60,7 +66,7 @@ if (macro === 'short-v-model') {
6066 } )
6167}
6268
63- const targetDirectory = path . resolve ( argv . _ [ 0 ] || '.' )
69+ const targetDirectory = path . resolve ( argv . _ . at ( - 1 ) || '.' )
6470
6571const files = await glob ( `${ targetDirectory } /**/*.vue` , {
6672 ignore : [
@@ -82,7 +88,7 @@ if (['jsx-directive', 'setup-sfc'].includes(macro)) {
8288
8389 await $ `${ sg } scan -c ${ config } -U --filter '^tsx v-' ${ targetDirectory } `
8490
85- if ( defineShortSlots )
91+ if ( defineSlots === 'define-short-slots' )
8692 await $ `${ sg } scan -c ${ config } -U --filter 'tsx define-short-slots' ${ targetDirectory } `
8793
8894 if ( macro === 'setup-sfc' ) {
0 commit comments