1
0
Fork 0
mirror of synced 2024-06-20 19:30:28 +12:00

fix: create app failing from unknown folder copy issues

This commit is contained in:
Michael Shanks 2020-07-14 07:02:46 +01:00
parent 0ca7649e85
commit 10b0f8c379
3 changed files with 23 additions and 0 deletions

View file

@ -11,6 +11,7 @@ const { exec } = require("child_process")
const sqrl = require("squirrelly")
const setBuilderToken = require("../../utilities/builder/setBuilderToken")
const fs = require("fs-extra")
const chmodr = require("../../utilities/chmodr")
exports.fetch = async function(ctx) {
const db = new CouchDB(ClientDb.name(getClientId(ctx)))
@ -138,6 +139,11 @@ const createEmptyAppPackage = async (ctx, app) => {
await copy(templateFolder, newAppFolder)
// this line allows full permission on copied files
// we have an unknown problem without this, whereby the
// files get weird permissions and cant be written to :(
await chmodr(newAppFolder, 0o777)
await updateJsonFile(join(appsFolder, app._id, "package.json"), {
name: npmFriendlyAppName(app.name),
})

View file

@ -0,0 +1,17 @@
const fs = require("fs-extra")
const { join } = require("path")
const chmodr = async (dir, perms) => {
const children = await fs.readdir(dir)
for (let child of children) {
const fullChildPath = join(dir, child)
const stat = await fs.stat(join(dir, child))
if (stat.isFile()) {
await fs.chmod(fullChildPath, perms)
} else {
await chmodr(fullChildPath, perms)
}
}
}
module.exports = chmodr