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

This commit is contained in:
Aaron Bieber 2023-05-31 19:07:12 -06:00 committed by PedroHLC ☭
parent 800399a2ce
commit d5b901282e
No known key found for this signature in database
GPG key ID: DF4C6898CBDC6DF5
2 changed files with 41 additions and 0 deletions

View file

@ -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 # see upstream issue https://github.com/dillonkearns/elm-pages/issues/305 for dealing with the read-only problem
preFixup = '' 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/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 = '' postFixup = ''

View file

@ -0,0 +1,40 @@
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")