Skip to content

Commit

Permalink
Merge pull request #7 from SimplyEdit/feature/reuse-simplyedit
Browse files Browse the repository at this point in the history
let requests to /js/simply-edit.js resolve even if they are not there…
  • Loading branch information
Hoxolotl authored Jun 7, 2024
2 parents bc75e19 + 38d7cc9 commit fd8cab5
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ app.whenReady().then(() => {
})
} else {
var target = __dirname + '/simplycode' + componentDirectory + '\/' + componentName;
if (fs.existsSync(target)){
if(fs.existsSync(target)) {

if (fs.lstatSync(target).isDirectory()) {
// Do the recursive read thing;
} else {
Expand All @@ -207,7 +208,7 @@ app.whenReady().then(() => {
})
}
} else {
return new Response('"Not found"', { status: 404})
return new Response("Not found", {"status" : 404})
}
}
break
Expand Down Expand Up @@ -243,14 +244,26 @@ app.whenReady().then(() => {
return new Response(filestuff, {
// headers: { 'content-type': 'text/html' }
})
} else {{
if (fs.existsSync(dataDir + componentDirectory + '\/' + componentName)){
const filestuff = fs.readFileSync(dataDir + componentDirectory + '\/' + componentName)

} else {
var target = dataDir + componentDirectory + '\/' + componentName;
if(fs.existsSync(target)) {
const filestuff = fs.readFileSync(target)

return new Response(filestuff, {
// headers: { 'content-type': 'text/html' }
})
} else {
return new Response('"Not found"', { status: 404})
if (
(componentPath === "/js/simply-edit.js") ||
(componentPath === "/js/simply.everything.js")
) {
const filestuff = fs.readFileSync(__dirname + '/simplycode' + componentDirectory + '\/' + componentName)
return new Response(filestuff, {
// headers: { 'content-type': 'text/html' }
})
}
return new Response("Not found", {"status" : 404})
}
}
break
Expand Down

0 comments on commit fd8cab5

Please sign in to comment.