Unverified Commit d5b90128 authored by Aaron Bieber's avatar Aaron Bieber Committed by PedroHLC ☭
Browse files

elm-pages: set files/dirs as +w when copied during elm-init

parent 800399a2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -247,6 +247,7 @@ in lib.makeScope pkgs.newScope (self: with self; {
          # see upstream issue https://github.com/dillonkearns/elm-pages/issues/305 for dealing with the read-only problem
          preFixup = ''
            patch $out/lib/node_modules/elm-pages/generator/src/codegen.js ${./packages/elm-pages-fix-read-only.patch}
            patch $out/lib/node_modules/elm-pages/generator/src/init.js ${./packages/elm-pages-fix-init-read-only.patch}
          '';

          postFixup = ''
+40 −0
Original line number Diff line number Diff line
diff --git a/generator/src/init.js b/generator/src/init.js
index 3d8548c..90ee20d 100644
--- a/generator/src/init.js
+++ b/generator/src/init.js
@@ -3,6 +3,21 @@ const copySync = require("fs-extra").copySync;
 const path = require("path");
 const kleur = require("kleur");
 
+let walknDo = function(somePath, doStuff) {
+  doStuff(somePath, true);
+  const dir = fs.readdirSync(somePath)
+  dir.forEach((i) => {
+    let p = path.join(somePath, i);
+    const s = fs.statSync(p)
+    if (s.isDirectory()) {
+      walknDo(p, doStuff)
+    } else {
+      doStuff(p);
+    }
+  });
+}
+
+
 /**
  * @param {string} name
  */
@@ -15,6 +30,13 @@ async function run(name) {
   if (!fs.existsSync(name)) {
     try {
       copySync(template, appRoot);
+      walknDo(appRoot, (file, isDir) => {
+        if (isDir) {
+          fs.chmodSync(file, 0o755);
+        } else {
+          fs.chmodSync(file, 0o644);
+        }
+      });
       fs.renameSync(
         path.resolve(appRoot, "gitignore"),
         path.resolve(appRoot, ".gitignore")