Skip to content
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

Only compile if there were no errors #93

Closed
jdcauley opened this issue Sep 7, 2013 · 12 comments
Closed

Only compile if there were no errors #93

jdcauley opened this issue Sep 7, 2013 · 12 comments

Comments

@jdcauley
Copy link

jdcauley commented Sep 7, 2013

Presently when I compile Harp excludes my image assets folder and my base js folder.

There may be a setting I'm missing or just something currently not supported.

Also is there a setting so that when I compile it only replaces changed files rather than wiping the entire previous compile?

@kennethormandy
Copy link
Collaborator

Hey @jdcauley, thanks for opening an issue.

That does sound a little strange. If the app was successfully compiled, the only reason something should be absent is if:

  • The folder or file starts with an underscore
  • You have a public directory and a harp.json file and those items are outside that folder.

Can you show what your directory structure looks like for the app? I’m sure we can get to the bottom of this.

In regards to your other question, would you mind explaining your use case for me? I just need to understand a little better. The previous files do get wiped out, yes. If they are actually unchanged, then they would get replaced with the same thing, since the same uncompiled versions would still be in your app.

Right now, Harp re-builds everything on purpose; even though you might not have changed index.md, for example, _layout.jade could be different, so the resulting index.html still needs to be generated. But I might be misunderstanding what you’re looking for, please let me know!

@jdcauley
Copy link
Author

jdcauley commented Sep 8, 2013

https://github.com/jdcauley/asthmasense.com

This is an example: I'm betting I'm missing something I'm my json file but I could find anything in docs

Jordan Cauley
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Saturday, September 7, 2013 at 4:00 PM, Kenneth Ormandy wrote:

Hey @jdcauley (https://github.com/jdcauley), thanks for opening an issue.
That does sound a little strange. If the app was successfully compiled, the only reason something should be absent is if:
The folder or file starts with an underscore
You have a public directory and a harp.json file and those items are outside that folder.

Can you show what your directory structure looks like for the app? I’m sure we can get to the bottom of this.
In regards to your other question, would you mind explaining your use case for me? I just need to understand a little better. The previous files do get wiped out, yes. If they are actually unchanged, then they would get replaced with the same thing, since the same uncompiled versions would still be in your app.
Right now, Harp re-builds everything on purpose; even though you might not have changed index.md (http://index.md), for example, _layout.jade could be different, so the resulting index.html still needs to be generated. But I might be misunderstanding what you’re looking for, please let me know!


Reply to this email directly or view it on GitHub (#93 (comment)).

@kennethormandy
Copy link
Collaborator

Thanks, that helps a lot. The main problem is that you’re getting a LESS error, do you get this message on harp compile?

{
  "source": "Less",
  "dest": "CSS",
  "filename": "/Users/kennethormandy/Sites/asthmasense.com/public/assets/less/accordion.less",
  "lineno": 8,
  "name": "NameError",
  "message": "variable @line-height-computed is undefined",
  "stack": "//\n// Accordion\n// --------------------------------------------------\n\n\n// Parent container\n.accordion {\n  margin-bottom: @line-height-computed;\n}\n\n// Group == heading + body\n.accordion-group {\n  margin-bottom: 2px;\n  border: 1px solid @accordion-border-color;\n  border-radius: @border-radius-base;\n}\n.accordion-heading {\n  border-bottom: 0;\n\n  .accordion-toggle {\n    display: block;\n    padding: 8px 15px;\n    cursor: pointer;\n  }\n}\n\n// Inner needs the styles because you can't animate properly with any styles on the element\n.accordion-inner {\n  padding: 9px 15px;\n  border-top: 1px solid @accordion-border-color;\n}\n"
}

We still need to improve the CLI error messages. The main thing is variable @line-height-computed is undefined in less/accordion.less. Another part of this is that Harp should probably remove the www folder if the compile was unsuccessful, so it’s not misleading as in this case.

The reason this error is happening is that Harp generate every CSS file that doesn’t start with an underscore. Unfortunately, most LESS libraries don’t follow the convention of using underscores for partials. So, you just need to put Bootstrap in an underscore directory so only the bootstrap.css file is generated, instead of every partial getting its own CSS file, too.

less/
  |- app.less
  +- _bootstrap/
      |- accordion.less
      |- alerts.less
      ...
      +- wells.less

Now, in your app.less file, just @import the main bootstrap.less:

@import "_bootstrap/bootstrap.less";

And remove @import "app.less"; from bootstrap.less. harp compile should work after that. If it’s easier to look at in context, here’s my fork of your repo.

We’d definitely like to give a very specific error message there to make it clear what’s going on, and I’ll update the LESS and Stylus docs. Any thoughts you have on making this clear would be greatly appreciated.

@jdcauley
Copy link
Author

jdcauley commented Sep 8, 2013

That error doesn't prevent the compile.  The site still comes out perfect except that I don't have a js or img folder included in the www.  

Sent from Mailbox for iPhone

On Sun, Sep 8, 2013 at 12:42 PM, Kenneth Ormandy notifications@github.com
wrote:

Thanks, that helps a lot. The main problem is that you’re getting a LESS error, do you get this message on harp compile?

{
  "source": "Less",
  "dest": "CSS",
  "filename": "/Users/kennethormandy/Sites/asthmasense.com/public/assets/less/accordion.less",
  "lineno": 8,
  "name": "NameError",
  "message": "variable @line-height-computed is undefined",
  "stack": "//\n// Accordion\n// --------------------------------------------------\n\n\n// Parent container\n.accordion {\n  margin-bottom: @line-height-computed;\n}\n\n// Group == heading + body\n.accordion-group {\n  margin-bottom: 2px;\n  border: 1px solid @accordion-border-color;\n  border-radius: @border-radius-base;\n}\n.accordion-heading {\n  border-bottom: 0;\n\n  .accordion-toggle {\n    display: block;\n    padding: 8px 15px;\n    cursor: pointer;\n  }\n}\n\n// Inner needs the styles because you can't animate properly with any styles on the element\n.accordion-inner {\n  padding: 9px 15px;\n  border-top: 1px solid @accordion-border-color;\n}\n"
}

We still need to improve the CLI error messages. The main thing is variable @line-height-computed is undefined in less/accordion.less. Another part of this is that Harp should probably remove the www folder if the compile was unsuccessful, so it’s not misleading as in this case.
The reason this error is happening is that Harp generate every CSS file that doesn’t start with an underscore. Unfortunately, most LESS libraries don’t follow the convention of using underscores for partials. So, you just need to put Bootstrap in an underscore directory so only the bootstrap.css file is generated, instead of every partial getting its own CSS file, too.

less/
  |- app.less
  +- _bootstrap/
      |- accordion.less
      |- alerts.less
      ...
      +- wells.less

Now, in your app.less file, just @import the main bootstrap.less:

@import "_bootstrap/bootstrap.less";

And remove @import "app.less"; from bootstrap.less. harp compile should work after that. If it’s easier to look at in context, here’s my fork of your repo.

We’d definitely like to give a very specific error message there to make it clear what’s going on, and I’ll update the LESS and Stylus docs. Any thoughts you have on making this clear would be greatly appreciated.

Reply to this email directly or view it on GitHub:
#93 (comment)

@kennethormandy
Copy link
Collaborator

That’s right, but I think that’s actually a problem with Harp. For your app, it was confusing because it seems like compile was completed successfully, but it actually wasn’t. What’s actually happening is Harp compiles as much as it can before it hits an error. Since there’s a LESS error, it stops. I don’t think Harp ever makes it to the images or JS folder because of that.

In terms of the technical implementation of harp compile, I think it should behave more like npm install; the package only appears if everything was successful. For example, maybe harp compile first generates a .www folder. Then, if the compile was successful (there were no LESS errors, etc.), rename it to www and replace the existing www folder if there is one. That way, you would only have a new compile folder if there were no errors. You would also keep your old compile folder if there were.

@jdcauley
Copy link
Author

I restructured my file and now its ignoring app.less altogether.

Jordan Cauley
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, September 8, 2013 at 12:42 PM, Kenneth Ormandy wrote:

Thanks, that helps a lot. The main problem is that you’re getting a LESS error, do you get this message on harp compile?
{ "source": "Less", "dest": "CSS", "filename": "/Users/kennethormandy/Sites/asthmasense.com/public/assets/less/accordion.less (http://asthmasense.com/public/assets/less/accordion.less)", "lineno": 8, "name": "NameError", "message": "variable @line-height-computed is undefined", "stack": "//\n// Accordion\n// --------------------------------------------------\n\n\n// Parent container\n.accordion {\n margin-bottom: @line-height-computed;\n}\n\n// Group == heading + body\n.accordion-group {\n margin-bottom: 2px;\n border: 1px solid @accordion-border-color;\n border-radius: @border-radius-base;\n}\n.accordion-heading {\n border-bottom: 0;\n\n .accordion-toggle {\n display: block;\n padding: 8px 15px;\n cursor: pointer;\n }\n}\n\n// Inner needs the styles because you can't animate properly with any styles on the element\n.accordion-inner {\n padding: 9px 15px;\n border-top: 1px solid @accordion-border-color;\n}\n" }
We still need to improve the CLI error messages. The main thing is variable @line-height-computed is undefined in less/accordion.less. Another part of this is that Harp should probably remove the www folder if the compile was unsuccessful, so it’s not misleading as in this case.
The reason this error is happening is that Harp generate every CSS file that doesn’t start with an underscore. Unfortunately, most LESS libraries don’t follow the convention of using underscores for partials. So, you just need to put Bootstrap in an underscore directory so only the bootstrap.css file is generated, instead of every partial getting its own CSS file, too.
less/ |- app.less +- _bootstrap/ |- accordion.less |- alerts.less ... +- wells.less
Now, in your app.less file, just @import the main bootstrap.less:
@import "_bootstrap/bootstrap.less";
And remove @import "app.less"; from bootstrap.less. harp compile should work after that. If it’s easier to look at in context, here’s my fork of your repo (https://github.com/kennethormandy/asthmasense.com).
We’d definitely like to give a very specific error message there to make it clear what’s going on, and I’ll update the LESS and Stylus docs. Any thoughts you have on making this clear would be greatly appreciated.


Reply to this email directly or view it on GitHub (#93 (comment)).

@jdcauley
Copy link
Author

As in on compile there is no app.css file.

Jordan Cauley
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, September 8, 2013 at 12:42 PM, Kenneth Ormandy wrote:

Thanks, that helps a lot. The main problem is that you’re getting a LESS error, do you get this message on harp compile?
{ "source": "Less", "dest": "CSS", "filename": "/Users/kennethormandy/Sites/asthmasense.com/public/assets/less/accordion.less (http://asthmasense.com/public/assets/less/accordion.less)", "lineno": 8, "name": "NameError", "message": "variable @line-height-computed is undefined", "stack": "//\n// Accordion\n// --------------------------------------------------\n\n\n// Parent container\n.accordion {\n margin-bottom: @line-height-computed;\n}\n\n// Group == heading + body\n.accordion-group {\n margin-bottom: 2px;\n border: 1px solid @accordion-border-color;\n border-radius: @border-radius-base;\n}\n.accordion-heading {\n border-bottom: 0;\n\n .accordion-toggle {\n display: block;\n padding: 8px 15px;\n cursor: pointer;\n }\n}\n\n// Inner needs the styles because you can't animate properly with any styles on the element\n.accordion-inner {\n padding: 9px 15px;\n border-top: 1px solid @accordion-border-color;\n}\n" }
We still need to improve the CLI error messages. The main thing is variable @line-height-computed is undefined in less/accordion.less. Another part of this is that Harp should probably remove the www folder if the compile was unsuccessful, so it’s not misleading as in this case.
The reason this error is happening is that Harp generate every CSS file that doesn’t start with an underscore. Unfortunately, most LESS libraries don’t follow the convention of using underscores for partials. So, you just need to put Bootstrap in an underscore directory so only the bootstrap.css file is generated, instead of every partial getting its own CSS file, too.
less/ |- app.less +- _bootstrap/ |- accordion.less |- alerts.less ... +- wells.less
Now, in your app.less file, just @import the main bootstrap.less:
@import "_bootstrap/bootstrap.less";
And remove @import "app.less"; from bootstrap.less. harp compile should work after that. If it’s easier to look at in context, here’s my fork of your repo (https://github.com/kennethormandy/asthmasense.com).
We’d definitely like to give a very specific error message there to make it clear what’s going on, and I’ll update the LESS and Stylus docs. Any thoughts you have on making this clear would be greatly appreciated.


Reply to this email directly or view it on GitHub (#93 (comment)).

@jdcauley
Copy link
Author

Got it will add appropriate bootstrap.less file tree later today.

Jordan Cauley
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, September 8, 2013 at 1:47 PM, Kenneth Ormandy wrote:

That’s right, but I think that’s actually a problem with Harp. For your app, it was confusing because it seems like compile was completed successfully, but it actually wasn’t. What’s actually happening is Harp compiles as much as it can before it hits an error. Since there’s a LESS error, it stops. I don’t think Harp ever makes it to the images or JS folder because of that.
In terms of the technical implementation of harp compile, I think it should behave more like npm install; the package only appears if everything was successful. For example, maybe harp compile first generates a .www folder. Then, if the compile was successful (there were no LESS errors, etc.), rename it to www and replace the existing www folder if there is one. That way, you would only have a new compile folder if there were no errors. You would also keep your old compile folder if there were.


Reply to this email directly or view it on GitHub (#93 (comment)).

@sintaxi
Copy link
Owner

sintaxi commented Sep 10, 2013

@jdcauley if you are still seeing problems can you send us a simplified version of your app that reproduces the problem?

@kennethormandy
Copy link
Collaborator

@sintaxi This is the app in question and this is one way of fixing it.

It’s an issue that’s come up before: LESS and Stylus don’t use the convention of underscores to denote partials. So, libraries tend to break until you put them into a directory with a leading underscore. There’s no bug here, but there is a bit of a hurdle for new users.

@jdcauley
Copy link
Author

I have resolved this issue, Thank you for all the help. The original file tree provide still caused some problems but I got everything sorted out.

I'm going to add my solution and my bootstrap file tree for anyone else who might want to use it.

Jordan Cauley
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Tuesday, September 10, 2013 at 8:34 PM, Kenneth Ormandy wrote:

@sintaxi (https://github.com/sintaxi) This is the app in question (https://github.com/jdcauley/asthmasense.com) and this is one way of fixing it (https://github.com/kennethormandy/asthmasense.com).
It’s an issue that’s come up before: LESS and Stylus don’t use the convention of underscores to denote partials. So, libraries tend to break until you put them into a directory with a leading underscore. There’s no bug here, but there is a bit of a hurdle for new users.


Reply to this email directly or view it on GitHub (#93 (comment)).

@jdcauley
Copy link
Author

Ok to close?

@jdcauley jdcauley closed this as completed May 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants