Skip to content

Commit

Permalink
fix: support watch upload of deeply nested files
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Oct 21, 2023
1 parent 55ef6e3 commit db8b460
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,23 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
}
if (skip) continue

let isDirectory = fs.existsSync(`${entryPath}/${file}`) && fs.lstatSync(`${entryPath}/${file}`).isDirectory();
let name = file
let source = ''

for (let i = 0; i < match.length; i++) {
skip = true
const filePath = path.resolve(entryPath, file);
if (filePath.startsWith(match[i])) {
skip = false
break;
} else if (isDirectory && match[i].startsWith(filePath)) {
skip = 'directory'
break;
}
}

if (skip) continue

let isDirectory = fs.existsSync(`${entryPath}/${file}`) && fs.lstatSync(`${entryPath}/${file}`).isDirectory();
let name = file
let source = ''
if (skip === true) continue

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

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

response = await runStore(newObject);
console.log(`Uploaded: ${entryPath}/${file}`, `To: ${pathname}`)
if (skip !== 'directory') {
if (!newObject.object._id)
newObject.$filter = {
query: [{ key: 'pathname', value: pathname, operator: '$eq' }]
}

response = await runStore(newObject);
console.log(`Uploaded: ${entryPath}/${file}`, `To: ${pathname}`)

if (response.error)
errorLog.push(response.error)
if (response.error)
errorLog.push(response.error)
}

if (isDirectory && pathname) {
let newEntry
Expand Down

0 comments on commit db8b460

Please sign in to comment.