@@ -13,7 +13,9 @@ class CommandMkdir extends CommandPolykey {
13
13
constructor ( ...args : ConstructorParameters < typeof CommandPolykey > ) {
14
14
super ( ...args ) ;
15
15
this . name ( 'mkdir' ) ;
16
- this . description ( 'Create a Directory within a Vault' ) ;
16
+ this . description (
17
+ 'Create a Directory within a Vault. Empty directories are not a part of the vault and will not be shared when cloning a Vault.' ,
18
+ ) ;
17
19
this . argument (
18
20
'<secretPath...>' ,
19
21
'Path to where the directory to be created, specified as <vaultName>:<directoryPath>' ,
@@ -62,28 +64,28 @@ class CommandMkdir extends CommandPolykey {
62
64
const writer = response . writable . getWriter ( ) ;
63
65
let first = true ;
64
66
for ( const [ vault , path ] of secretPaths ) {
65
- await writer . write ( {
66
- nameOrId : vault ,
67
- dirName : path ,
68
- metadata : first
69
- ? { ...auth , options : { recursive : options . recursive } }
70
- : undefined ,
71
- } ) ;
67
+ if ( first ) {
68
+ first = false ;
69
+ await writer . write ( {
70
+ nameOrId : vault ,
71
+ dirName : path ,
72
+ metadata : {
73
+ ...auth ,
74
+ options : { recursive : options . recursive } ,
75
+ } ,
76
+ } ) ;
77
+ } else {
78
+ await writer . write ( { nameOrId : vault , dirName : path } ) ;
79
+ }
72
80
}
73
81
await writer . close ( ) ;
74
82
return response ;
75
83
} , meta ) ;
76
84
77
- // As git does not track empty directories in version control, we need
78
- // to inform the user about this.
79
- process . stderr . write (
80
- 'WARNING: Empty directories will not be affected by modifications to the vault state (version change, sharing/cloning, etc.)\n' ,
81
- ) ;
82
-
83
- let shouldError = false ;
85
+ let hasErrored = false ;
84
86
for await ( const result of response . readable ) {
85
87
if ( result . type === 'error' ) {
86
- shouldError = true ;
88
+ hasErrored = true ;
87
89
let message : string = '' ;
88
90
switch ( result . code ) {
89
91
case 'ENOENT' :
@@ -102,7 +104,7 @@ class CommandMkdir extends CommandPolykey {
102
104
) ;
103
105
}
104
106
}
105
- if ( shouldError ) {
107
+ if ( hasErrored ) {
106
108
throw new ErrorPolykeyCLIMakeDirectory (
107
109
'Failed to create one or more directories' ,
108
110
) ;
0 commit comments