@@ -121,7 +121,7 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
121121
122122
123123 crud . socket . create ( config )
124- config . broadcastSender = false
124+ // config.broadcastBrowser = false
125125
126126 if ( config . email && config . password ) {
127127 let request = {
@@ -195,14 +195,9 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
195195 let name = file
196196 let source = ''
197197 let directoryName = parentDirectory || '' ;
198- let parentDirectoryOnly = parentDirectory || '' ;
199- let index = parentDirectoryOnly . lastIndexOf ( '/' ) + 1
200- if ( parentDirectoryOnly && index ) {
201- parentDirectoryOnly = parentDirectoryOnly . substring ( index )
202- }
198+
203199 const fileExtension = path . extname ( file ) ;
204200 let mimeType = mimeTypes [ fileExtension ]
205- let pathName = '' ;
206201
207202 if ( ! directoryName && directory . object && directory . object . directory )
208203 directoryName = directory . object . directory . replace ( '{{directory}}' , '' ) . trim ( )
@@ -211,12 +206,23 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
211206
212207 if ( exclude && exclude . includes ( directoryName ) ) continue
213208
209+ let Path = '' ;
214210 if ( directoryName . endsWith ( "/" ) )
215- pathName = directoryName + name
211+ Path = directoryName
216212 else if ( directoryName )
217- pathName = directoryName + '/' + name
213+ Path = directoryName + '/'
218214 else
219- pathName = '/' + name
215+ Path = '/'
216+
217+ let pathname = Path + name ;
218+
219+ let folder = ''
220+ if ( Path === '/' )
221+ folder = Path
222+ else {
223+ let result = Path . split ( '/' ) ;
224+ folder = result [ result . length - 2 ] ;
225+ }
220226
221227 if ( isDirectory )
222228 mimeType = "text/directory"
@@ -226,9 +232,9 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
226232 let values = {
227233 '{{name}}' : name ,
228234 '{{source}}' : source ,
229- '{{directory}}' : directoryName ,
230- '{{parentDirectory }}' : parentDirectoryOnly ,
231- '{{path }}' : pathName ,
235+ '{{directory}}' : folder ,
236+ '{{path }}' : Path ,
237+ '{{pathname }}' : pathname ,
232238 '{{content-type}}' : mimeType
233239 }
234240
@@ -239,10 +245,10 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
239245 object . src = "{{source}}"
240246 if ( ! object . directory )
241247 object . directory = "/{{directory}}"
242- if ( ! object . parentDirectory )
243- object . parentDirectory = "{{parentDirectory}}"
244248 if ( ! object . path )
245249 object . path = "{{path}}"
250+ if ( ! object . pathname )
251+ object . pathname = "{{pathname}}"
246252 if ( ! object [ "content-type" ] )
247253 object [ "content-type" ] = '{{content-type}}'
248254 if ( ! object . public && object . public != false && object . public != 'false' )
@@ -259,7 +265,7 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
259265 if ( variables ) {
260266 for ( let variable of variables ) {
261267 if ( variable == '{{directory}}' ) {
262- if ( parentDirectory )
268+ if ( folder )
263269 newObject . object [ key ] = values [ variable ]
264270 else
265271 newObject . object [ key ] = newObject . object [ key ] . replace ( variable , '' ) ;
@@ -276,21 +282,21 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
276282
277283 if ( ! newObject . object . _id )
278284 newObject . $filter = {
279- query : [ { key : 'path ' , value : pathName , operator : '$or' } ]
285+ query : [ { key : 'pathname ' , value : pathname , operator : '$or' } ]
280286 }
281287
282288 response = await runStore ( newObject ) ;
283289 if ( response . error )
284290 errorLog . push ( response . error )
285291
286- if ( isDirectory && pathName ) {
292+ if ( isDirectory && pathname ) {
287293 let newEntry
288294 if ( entry . endsWith ( "/" ) )
289295 newEntry = entry + name
290296 else
291297 newEntry = entry + '/' + name
292298
293- await runFiles ( directory , newEntry , exclude , pathName )
299+ await runFiles ( directory , newEntry , exclude , pathname )
294300 }
295301 }
296302 if ( errorLog . length )
@@ -377,9 +383,9 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
377383 }
378384
379385 let data = { array, object }
380- if ( ! object . _id && object . path )
386+ if ( ! object . _id && object . pathname )
381387 data . $filter = {
382- query : [ { key : 'path ' , value : object . path , operator : '$or' } ]
388+ query : [ { key : 'pathname ' , value : object . pathname , operator : '$or' } ]
383389 }
384390
385391 if ( match . length && isMatch )
0 commit comments