nixpkgs/pkgs/development/compilers/elm/packages/elm-pages-fix-init-read-only.patch
2023-10-05 10:37:37 -03:00

39 lines
1.1 KiB
Diff

diff --git a/generator/src/init.js b/generator/src/init.js
index 06386ff..7127dae 100644
--- a/generator/src/init.js
+++ b/generator/src/init.js
@@ -6,6 +6,20 @@ import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
+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
*/
@@ -18,6 +32,13 @@ export async function run(name) {
if (!fs.existsSync(name)) {
try {
await fsExtra.copy(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")