Skip to content

Don't destroy existing outputPath on fail - #253

Open
remy wants to merge 1 commit into
sintaxi:masterfrom
remy:master
Open

Don't destroy existing outputPath on fail#253
remy wants to merge 1 commit into
sintaxi:masterfrom
remy:master

Conversation

@remy

@remy remy commented Feb 21, 2014

Copy link
Copy Markdown
Contributor

Compile writes out to os.tmpdir, and if successful, it then moves the directory to the user defined output path and cleans up after itself. This allows for a compile to fail, but won't blow away the existing directory.

I was using Harp for our dev and was thrown off by it destroying the contents of www when it errored. So I fixed that. Hopefully useful to others and PR-mergable.

Compile writes out to os.tmpdir, and if successful, it then moves the directory to the user defined output path and cleans up after itself. This allows for a compile to fail, but won't blow away the existing directory.

I was using Harp for our dev and was thrown off by it destroying the contents of www when it errored. So I fixed that. Hopefully useful to others and PR-mergable.
@kevinsimper

Copy link
Copy Markdown

Nice as i have also experienced the same thing and I had not put it in git.

This properly fixes this issue #92

@remy

remy commented Feb 21, 2014

Copy link
Copy Markdown
Contributor Author

For further context, we're planning to use Harp in production of jsbin.com in a submodule that will get a git hook to tell it to recompile. And even though we're doing all we can to protect from this hook being called if the tests fail, it's possible it could run, and I want to ensure the "live content" is protected.

@kennethormandy

Copy link
Copy Markdown
Collaborator

Fantastic, thank you for doing this! We weren’t happy with the existing behaviour, and this sounds a lot better. I believe @silentrob had started something that would improve #19 or #93, so hopefully both your solutions can work together.

@sintaxi

sintaxi commented Feb 21, 2014

Copy link
Copy Markdown
Owner

Yeah lets get @silentrob in the loop on this. He had a PR last week to address this issue but I had a few concerns with it.

Comment thread lib/index.js

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "www"... bit should probably just be a random hash: crypto.createHash('md5').update(Math.random() + '').digest('hex') as the pathname.

@kennethormandy

Copy link
Copy Markdown
Collaborator

We will either have to add a -f flag (or something) or change how the tests work. Unfortunately it seems like the ones using compile don’t run properly.

@kennethormandy kennethormandy modified the milestone: Harp v0.12.0 Mar 14, 2014
@remy

remy commented Sep 5, 2014

Copy link
Copy Markdown
Contributor Author

Though this doesn't merge anymore (I'm sure it'll be simple to resolve) what's the thoughts on preserving the output directory until the compile is successful?

I keep coming across cases where I need this. The latest is a blog containing 300 posts takes about 120 seconds to compile, so that's 2 minutes where the entire web site is blown away whilst the compile does its job.

@sintaxi

sintaxi commented Oct 3, 2014

Copy link
Copy Markdown
Owner

I've dropped the ball on this one. This really should get merged. Sorry @remy

@ixley

ixley commented Oct 24, 2014

Copy link
Copy Markdown

Any update on this? I'm using Github pages to host a site (meaning I need to compile to the root directory first. Unfortunately, this was the first time I realized that Harp clears the target directory, which is great in most contexts, but not when I need to keep certain files like a subrepo, script and readme in the root but not source.

I found this from #346. Does this issue also include the ability to flag to not overwrite the directory, or is it just addressing overwrites for failures?

@kevinsimper

Copy link
Copy Markdown

@ixley You can follow this tutorial on how to do it with github pages

http://harpjs.com/docs/deployment/github-pages

@ixley

ixley commented Oct 24, 2014

Copy link
Copy Markdown

Thanks @kevinsimper - that's pretty much the process I am using, but the problem I'm having is that I have files in my build/root directory that I don't want to or can't duplicate in my src directory. These include the README (not a huge deal if it had to be duplicated), a shell script (would be confusing if it were duplicated unnecessarily), and a subrepository (which needs to exist as a protected directory in the root), but obviously all these things get overwritten when I compile my files.

@kevinsimper

Copy link
Copy Markdown

@ixley I do have it like you say, I have that on a master branch and then have a script which automaticly checkouts gh-pages and commits on that branch.

@ixley

ixley commented Oct 24, 2014

Copy link
Copy Markdown

Thanks @kevinsimper. Just emailed you directly so I don't clutter up this thread more.

@mderazon

mderazon commented Nov 1, 2014

Copy link
Copy Markdown

@kevinsimper can you share a gist of your script perhaps ? are you able to automate the process somehow with GH post commit hooks ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants