1
0
Fork 0
mirror of synced 2024-06-27 18:40:42 +12:00

Merge pull request #439 from mjashanks/master

fix: create app failing from unknown folder copy issues
This commit is contained in:
Martin McKeaveney 2020-07-14 07:29:08 +01:00 committed by GitHub
commit 82356de1e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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