Skip to content

Commit db8b460

Browse files
committed
fix: support watch upload of deeply nested files
1 parent 55ef6e3 commit db8b460

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/server.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,23 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
176176
}
177177
if (skip) continue
178178

179+
let isDirectory = fs.existsSync(`${entryPath}/${file}`) && fs.lstatSync(`${entryPath}/${file}`).isDirectory();
180+
let name = file
181+
let source = ''
182+
179183
for (let i = 0; i < match.length; i++) {
180184
skip = true
181185
const filePath = path.resolve(entryPath, file);
182186
if (filePath.startsWith(match[i])) {
183187
skip = false
184188
break;
189+
} else if (isDirectory && match[i].startsWith(filePath)) {
190+
skip = 'directory'
191+
break;
185192
}
186193
}
187194

188-
if (skip) continue
189-
190-
let isDirectory = fs.existsSync(`${entryPath}/${file}`) && fs.lstatSync(`${entryPath}/${file}`).isDirectory();
191-
let name = file
192-
let source = ''
195+
if (skip === true) continue
193196

194197
const fileExtension = path.extname(file);
195198
let mimeType = mimeTypes[fileExtension]
@@ -267,16 +270,19 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
267270
}
268271
}
269272

270-
if (!newObject.object._id)
271-
newObject.$filter = {
272-
query: [{ key: 'pathname', value: pathname, operator: '$eq' }]
273-
}
274273

275-
response = await runStore(newObject);
276-
console.log(`Uploaded: ${entryPath}/${file}`, `To: ${pathname}`)
274+
if (skip !== 'directory') {
275+
if (!newObject.object._id)
276+
newObject.$filter = {
277+
query: [{ key: 'pathname', value: pathname, operator: '$eq' }]
278+
}
279+
280+
response = await runStore(newObject);
281+
console.log(`Uploaded: ${entryPath}/${file}`, `To: ${pathname}`)
277282

278-
if (response.error)
279-
errorLog.push(response.error)
283+
if (response.error)
284+
errorLog.push(response.error)
285+
}
280286

281287
if (isDirectory && pathname) {
282288
let newEntry

0 commit comments

Comments
 (0)