@@ -3,6 +3,7 @@ import Ora from "ora";
33import { getConfig , saveConfig } from "../utils/config" ;
44import { defaultConfig , LocaleCode , resolveLocaleCode , bucketTypes } from "@lingo.dev/_spec" ;
55import fs from "fs" ;
6+ import path from "path" ;
67import { spawn } from "child_process" ;
78import _ from "lodash" ;
89import { confirm } from "@inquirer/prompts" ;
@@ -67,24 +68,26 @@ export default new InteractiveCommand()
6768 . default ( "json" ) ,
6869 )
6970 . addOption (
70- new InteractiveOption ( "-p, --paths < path...> " , "List of paths for the bucket" )
71+ new InteractiveOption ( "-p, --paths [ path...] " , "List of paths for the bucket" )
7172 . argParser ( ( value ) => {
73+ if ( ! value || value . length === 0 ) return [ ] ;
7274 const values = value . includes ( "," ) ? value . split ( "," ) : value . split ( " " ) ;
7375
74- for ( const path of values ) {
76+ for ( const p of values ) {
7577 try {
76- const stats = fs . statSync ( path ) ;
78+ const dirPath = path . dirname ( p ) ;
79+ const stats = fs . statSync ( dirPath ) ;
7780 if ( ! stats . isDirectory ( ) ) {
78- throw new Error ( `${ path } is not a directory` ) ;
81+ throw new Error ( `${ dirPath } is not a directory` ) ;
7982 }
8083 } catch ( err ) {
81- throw new Error ( `Invalid directory path: ${ path } ` ) ;
84+ throw new Error ( `Invalid path: ${ p } ` ) ;
8285 }
8386 }
8487
8588 return values ;
8689 } )
87- . default ( "." ) ,
90+ . default ( [ ] ) ,
8891 )
8992 . action ( async ( options ) => {
9093 const settings = getSettings ( undefined ) ;
@@ -102,7 +105,9 @@ export default new InteractiveCommand()
102105 newConfig . locale . source = options . source ;
103106 newConfig . locale . targets = options . targets ;
104107 newConfig . buckets = {
105- [ options . bucket ] : options . paths ,
108+ [ options . bucket ] : {
109+ include : options . paths || [ ] ,
110+ } ,
106111 } ;
107112
108113 await saveConfig ( newConfig ) ;
0 commit comments