fix: create app failing from unknown folder copy issues
This commit is contained in:
parent
0ca7649e85
commit
10b0f8c379
|
@ -11,6 +11,7 @@ const { exec } = require("child_process")
|
||||||
const sqrl = require("squirrelly")
|
const sqrl = require("squirrelly")
|
||||||
const setBuilderToken = require("../../utilities/builder/setBuilderToken")
|
const setBuilderToken = require("../../utilities/builder/setBuilderToken")
|
||||||
const fs = require("fs-extra")
|
const fs = require("fs-extra")
|
||||||
|
const chmodr = require("../../utilities/chmodr")
|
||||||
|
|
||||||
exports.fetch = async function(ctx) {
|
exports.fetch = async function(ctx) {
|
||||||
const db = new CouchDB(ClientDb.name(getClientId(ctx)))
|
const db = new CouchDB(ClientDb.name(getClientId(ctx)))
|
||||||
|
@ -138,6 +139,11 @@ const createEmptyAppPackage = async (ctx, app) => {
|
||||||
|
|
||||||
await copy(templateFolder, newAppFolder)
|
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"), {
|
await updateJsonFile(join(appsFolder, app._id, "package.json"), {
|
||||||
name: npmFriendlyAppName(app.name),
|
name: npmFriendlyAppName(app.name),
|
||||||
})
|
})
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue