raco pollen clone deletes current directory if destination is . #56

Closed
opened 10 years ago by frenchy64 · 4 comments
frenchy64 commented 10 years ago (Migrated from github.com)

I structured my project with a pollen-src directory, then I ran raco pollen clone pollen-src/ . at the root of my project and my project was deleted, as well as the root directory the project lives in.

I structured my project with a `pollen-src` directory, then I ran `raco pollen clone pollen-src/ .` at the root of my project and my project was deleted, as well as the root directory the project lives in.
mbutterick commented 10 years ago (Migrated from github.com)

Right, because during a clone operation, the target directory gets deleted, and then replaced with the new cloned directory. In this case, because the target directory contained the source folder, it got deleted too.

But I agree that behavior is too easy to trigger accidentally, so I’ve made a few changes:

  1. clone is now called publish because clone suggests a duplicate, but in fact many files are being left behind (e.g., Pollen source files and whatnot);

  2. The docs now emphasize that publish will overwrite a directory at the destination if it exists;

  3. raco pollen publish will raise an error if the source directory is inside the target directory (which doesn’t make sense) or if you try to use the current working directory as the target directory.

BTW if your original intention was to move or copy the files, that’s not what raco pollen publish is for — use mv or cp.

Right, because during a `clone` operation, the target directory gets deleted, and then replaced with the new cloned directory. In this case, because the target directory contained the source folder, it got deleted too. But I agree that behavior is too easy to trigger accidentally, so I’ve made a few changes: 1) `clone` is now called `publish` because `clone` suggests a duplicate, but in fact many files are being left behind (e.g., Pollen source files and whatnot); 2) The docs now emphasize that `publish` will overwrite a directory at the destination if it exists; 3) `raco pollen publish` will raise an error if the source directory is inside the target directory (which doesn’t make sense) or if you try to use the current working directory as the target directory. BTW if your original intention was to move or copy the files, that’s not what `raco pollen publish` is for — use `mv` or `cp`.
mbutterick commented 10 years ago (Migrated from github.com)

PS. As I already concede in the docs for raco pollen publish, “This function is pretty lame, and I invite suggestions for improvement.”

PS. As I [already concede in the docs](http://pkg-build.racket-lang.org/doc/pollen/raco-pollen.html) for `raco pollen publish`, “This function is pretty lame, and I invite suggestions for improvement.”
frenchy64 commented 10 years ago (Migrated from github.com)

My original intention was to have a directory structure like

index.html
post1.html
pollen-src/index.html.pm
pollen-src/post1.html.pm

with the .html files being rendered automatically via raco pollen clone.

I got the idea from this pollen repo, which implements this manually.

My original intention was to have a directory structure like ``` index.html post1.html pollen-src/index.html.pm pollen-src/post1.html.pm ``` with the `.html` files being rendered automatically via `raco pollen clone`. I got the idea from [this](https://github.com/makzan/web-layout-with-flexbox/blob/gh-pages/pollen-src/render.sh) pollen repo, which implements this manually.
mbutterick commented 10 years ago (Migrated from github.com)

raco pollen publish (né clone) doesn’t do any file rendering — it’s just a way of copying a Pollen project directory without certain files. (Notice in the example you cite, there’s a call to raco pollen render index.ptree earlier in the script, which accomplishes the rendering.)

One issue with the example you link to — I don’t want to say that gentleman is doing it wrong, but I think he’s making things hard for himself — is that his CSS, Javascript, and webfonts are all in the directory above his pollen-src. That means he can’t use the Pollen project server to preview and test his files within pollen-src. Also, when the source and destination directories are overlapping, it creates the potential for headaches.

index.html
post1.html
css/
js/
webfonts/
pollen-src/index.html.pm
pollen-src/post1.html.pm

The path of less resistance is to put all the source-side resources together:

pollen-src/index.html.pm
pollen-src/post1.html.pm
pollen-src/css/
pollen-src/js/
pollen-src/webfonts/

Render the project in-place:

pollen-src/index.html.pm
pollen-src/index.html
pollen-src/post1.html.pm
pollen-src/post1.html
pollen-src/css/
pollen-src/js/
pollen-src/webfonts/

And then raco pollen publish pollen-src elsewhere:

publish/index.html
publish/post1.html
publish/css/
publish/js/
publish/webfonts/

pollen-src/index.html.pm
pollen-src/index.html
pollen-src/post1.html.pm
pollen-src/post1.html
pollen-src/css/
pollen-src/js/
pollen-src/webfonts/
`raco pollen publish` (né `clone`) doesn’t do any file rendering — it’s just a way of copying a Pollen project directory without certain files. (Notice in the example [you cite](https://github.com/makzan/web-layout-with-flexbox/blob/gh-pages/pollen-src/render.sh), there’s a call to `raco pollen render index.ptree` earlier in the script, which accomplishes the rendering.) One issue with the [example you link to](https://github.com/makzan/web-layout-with-flexbox/blob/gh-pages/pollen-src/render.sh) — I don’t want to say that gentleman is doing it wrong, but I think he’s making things hard for himself — is that his CSS, Javascript, and webfonts are all in the directory **above** his `pollen-src`. That means he can’t use the Pollen project server to preview and test his files within `pollen-src`. Also, when the source and destination directories are overlapping, it creates the potential for headaches. ``` index.html post1.html css/ js/ webfonts/ pollen-src/index.html.pm pollen-src/post1.html.pm ``` The path of less resistance is to put all the source-side resources together: ``` pollen-src/index.html.pm pollen-src/post1.html.pm pollen-src/css/ pollen-src/js/ pollen-src/webfonts/ ``` Render the project in-place: ``` pollen-src/index.html.pm pollen-src/index.html pollen-src/post1.html.pm pollen-src/post1.html pollen-src/css/ pollen-src/js/ pollen-src/webfonts/ ``` And then `raco pollen publish pollen-src` elsewhere: ``` publish/index.html publish/post1.html publish/css/ publish/js/ publish/webfonts/ pollen-src/index.html.pm pollen-src/index.html pollen-src/post1.html.pm pollen-src/post1.html pollen-src/css/ pollen-src/js/ pollen-src/webfonts/ ```
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen#56
Loading…
There is no content yet.