-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new-package
command fails on "Adding preview folder"
#326
Comments
Possible fix could be changing function createReviewConfig(directory, template) {
const destinationPath = path.join(directory, 'ReviewConfig.elm');
fs.copyFileSync(
path.join(__dirname, '../init-templates/', template),
destinationPath
);
fs.chmodSync(destinationPath, 0o644); // Set permissions to be writable by owner
} |
Hi @pete-murphy 👋 Thanks for the detailed issue! I have very little knowledge of Nix, so pardon my confusion. I'm still confused as to which files (or folders?) require write permissions. The write permission not be set on the created Do you know if other files created by |
The
Just removing these lines fs.writeFileSync(
previewReviewConfigPath,
previewReviewConfig.replace(/RULENAME_TO_REPLACE/g, ruleName)
); from the
But looking at the permissions, any files that were copied are indeed missing writable permissions:
I think what I would expect to see is: ❯ tree -p elm-review-x
[drwxr-xr-x] elm-review-x
├── [-rw-r--r--] LICENSE
├── [-rw-r--r--] README.md
├── [drwxr-xr-x] elm-review-package-tests
- │ ├── [-r--r--r--] check-examples-were-updated.js
- │ ├── [-r--r--r--] check-previews-compile.js
- │ └── [dr-xr-xr-x] helpers
- │ ├── [-r--r--r--] ansi.js
- │ └── [-r--r--r--] find-configurations.js
+ │ ├── [-rw-r--r--] check-examples-were-updated.js
+ │ ├── [-rw-r--r--] check-previews-compile.js
+ │ └── [drwxr-xr-x] helpers
+ │ ├── [-rw-r--r--] ansi.js
+ │ └── [-rw-r--r--] find-configurations.js
├── [-rw-r--r--] elm-tooling.json
├── [-rw-r--r--] elm.json
├── [drwxr-xr-x] maintenance
- │ ├── [-r--r--r--] MAINTENANCE.md
- │ └── [-r-xr-xr-x] update-examples-from-preview.js
+ │ ├── [-rw-r--r--] MAINTENANCE.md
+ │ └── [-rwxr-xr-x] update-examples-from-preview.js
├── [-rw-r--r--] package.json
├── [drwxr-xr-x] preview
│ ├── [-rw-r--r--] elm.json
│ └── [drwxr-xr-x] src
- │ └── [-r--r--r--] ReviewConfig.elm
+ │ └── [-rw-r--r--] ReviewConfig.elm
├── [drwxr-xr-x] review
│ ├── [-rw-r--r--] elm.json
│ └── [drwxr-xr-x] src
│ └── [-rw-r--r--] ReviewConfig.elm
├── [drwxr-xr-x] src
│ └── [-rw-r--r--] X.elm
└── [drwxr-xr-x] tests
└── [-rw-r--r--] XTest.elm
10 directories, 17 files |
Maybe another possibility is to avoid using async function copyFiles(srcFolder, destFolder, files) {
const promises = files.map(async (file) => {
const src = path.join(srcFolder, file);
const srcContents = await readFile(src);
const dest = path.join(destFolder, file);
await fsp.writeFile(dest, srcContents);
});
await Promise.all(promises);
} And use that in place of these
This way we're just copying file contents and not the permissions. |
Version info:
This is likely specific to Nix-installed
elm-review
, because if I install the same version via NPM I'm able to run theelm-review new-package
command successfully.What I think is happening: I've noticed when running
elm-review init
(using the Nix-installedelm-review
), that the generatedReviewConfig.elm
is read-only. I'm guessing this has to do with these linesnode-elm-review/lib/init.js
Lines 197 to 202 in 18e38de
elm-review
is installed via Nix, because all files in Nix store are read-only from what I understand, and the copied files will also copy the permissions.See the permissions for the
ReviewConfig
created by Nix-installedelm-review
compared to NPM-installed
The
new-package
script then tries to write to that file, in these linesnode-elm-review/lib/new-package.js
Lines 202 to 206 in 5f2fcc3
The text was updated successfully, but these errors were encountered: