Fork me on GitHub
#boot
<
2016-11-01
>
richiardiandrea00:11:08

for this I think you will need to open an issue on the project, probably a PR with some sort of "ignore this dir" option in boot-sass can solve it (few lines of code)...another workaround would be to position the task that adds node_modules after sass

ag00:11:52

right… trying that

ag00:11:31

but then… I can’t have @imports in my sass file that referes to anything in node_modules

ag00:11:52

gotttammit.... every time I think I’m out… they pull me back. I thought I’m done dealing with javascript-land mess. I guess I’m not

richiardiandrea00:11:44

look, open an issue, the PR is simple stuff, I opened the code...it is better though to ask @juhoteperi what is the best course of action, maybe he has some other idea

richiardiandrea00:11:09

also, you could use mathias/boot-sassc which has more control over what is compiled

ag00:11:25

thanks @richiardiandrea! I have created an issue and I’ll try mathias’s lib in the meantime. Although it’s deprecated

richiardiandrea00:11:26

np 😉 hopefully this whole thing will help yourself and others (I'll follow the issue)

grounded_sage07:11:23

Is there anyone out there who could give me some help with my boot config?

dominicm08:11:52

@ag quite late to this party, but to give you some reasoning, the _ prefix is a standard in the sass community for indicating it's not an entrypoint.

pseud13:11:47

Anyone know of a nice workflow for running tests via boot ? Maybe with a bit of spec magic show-cased ?

dave14:11:04

@pseud i’m a fan of running boot watch test (or boot watch speak test if you want pass/fail sounds)

dave14:11:13

the tests are re-run each time you save a file

dave14:11:36

i think the test task only does clojure.test tests though

dave14:11:50

but there are other boot tasks like boot-expectations, etc.

dave14:11:11

so far i’ve been satisfied with clojure.test, which is maybe not the most popular perspective 🙂

jannis15:11:31

Hmm, is it possible to wrap existing tasks in a pod (e.g. to add the dependencies that include the wrapped tasks)?

pseud15:11:20

Is there any examples (that you know of) showcasing testing of a library that contains cljs, clj and cljc code ? I’m thinking I would want to exercise the cljc code (the api) in both cljs and clj mode to see if the platform-specific code holds up

martinklepsch15:11:02

@jannis not possible. Somewhere there is a with-env option that sets the env before and after the task so that pods created by the task see a different env but thats more of a hack than a solution

dave15:11:21

@pseud: another example: https://github.com/daveyarwood/music-theory/blob/master/build.boot this library is cljc only, but the tests are run via boot-test and boot-cljs test to test both platforms

martinklepsch15:11:50

err, it's a with-env macro ... 🙂

pseud15:11:56

@jannis @dave - thanks a lot 🙂 I’ll get to analyzing those 🙂

lwhorton16:11:52

hmm, I can’t find an example anywhere of passing command line args though a deftask

lwhorton16:11:36

if I had (deftask foo [d debug bool “”] (comp (another-task debug)), how do I pass that debug into deftask another-task [d debug bool “”]?

lwhorton16:11:23

I can just make another-task a regular defn, but that disallows me from calling it from the boot cli (without doing it through foo)

micha16:11:03

@lwhorton you can do like

micha16:11:36

(deftask foo
  [d debug bool ""]
  (comp
    (another-task :debug debug)
    ...

richiardiandrea16:11:39

@micha a question, is there a way to add a directory to a fileset and then get it back so that I can write things in it? I know it would make it immutable, but I am trying to get around this while working on figwheel

richiardiandrea16:11:17

the only super hack I found working is this horrible thing below:

user-resource-dirs (var-get (resolve 'boot.core/user-resource-dirs))
user-resource-dir (-> (user-resource-dirs) first)

micha16:11:55

@richiardiandrea not sure what you mean there?

richiardiandrea16:11:20

basically I need to tell figwheel where to write, my first idea was to pass a tmp-dir to the fileset and pass tmp-dir

micha16:11:59

yeah that would be what i would do too

richiardiandrea16:11:03

but the fileset will not include the tmp-dir, only a copy of it from what I see

richiardiandrea16:11:17

(unless I am doing something stupid)

micha16:11:29

you can add the temp dir to the fileset

richiardiandrea16:11:13

mmm I will try again, in theory that was my first idea, but it was not working as I expected

richiardiandrea16:11:30

meaning (:directories (boot/get-env)) did not contain my temp dir

micha16:11:38

maybe you let figwheel go crazy in some directory

micha16:11:43

and you periodically poll that

richiardiandrea16:11:46

by poll you mean use boot/sync-user-dirs! programmatically ?

micha16:11:12

hm i am probably not understanding the requirements

micha16:11:26

i guess it's all tightly coupled with figwheel

micha16:11:32

so you can't really isolate it

richiardiandrea16:11:31

exactly, I need basically to feed it a dir, then sync manually or use a dir already added to the fileset (this is why I was using boot.core/user-resource-dirs), moreover, figwheel only serves using resource-response

richiardiandrea16:11:21

my workaround works but feels hackish...I wanted to understand if it is the only way out 😉

micha16:11:59

if something is writing to the fileset directories it could cause problems

micha16:11:25

those files are hard links to content-addressed blob files

micha16:11:33

so if you write to them the content is different

richiardiandrea16:11:36

yeah that is what I was afraid of

richiardiandrea16:11:53

but if I use a tmp-dir, then I need to find a way to say "hey, I changed the tmp-dir", please update my fileset

richiardiandrea16:11:39

because from what I see the tmp-dir is not used directly but just "copied" in the fileset

richiardiandrea17:11:14

(which makes sense given that the fileset is immutable)

ag18:11:32

hey guys… can someone guide me through writing my own custom task that uses dosh? For example I I want to run something like sassc src/sass/main.sass > target/css/main.css. I know there are community tasks that handle sass already. I just want to learn how to do this without. So as I understand I need to use with-pre-wrap fileset and then run dosh in there. But how do I grab result of dosh command and make commit!, not very clear

micha18:11:18

@ag you want to create a temp dir for your task to write files in

micha18:11:24

then you add that temp dir to the fileset

micha18:11:32

for example:

micha18:11:58

basically you have to have sassc or whatever write to a directory you make with tmp-dir!

micha18:11:05

then you can add that dir to the fileset

ag18:11:58

oh… ok… I’ll try to search for tmp-dir! in github. maybe find some sample snippets. thanks @micha

micha18:11:52

it's boot.core/tmp-dir!

micha18:11:00

ah yeah that's a good example

ag19:11:45

thank you guys!

ag21:11:53

hey guys.. dubbing into tmp-dir! why something like this would report that directory doesn’t exist:

(deftask sassc []
  (with-pre-wrap fileset
    (let [tmp (tmp-dir!)]
      (dosh (str "echo FOO! > " (.getPath tmp) "/foo.txt")))))
I know I need to do add-resource and commit! but it fails way before I get to do that

micha21:11:06

@ag that error is usually caused by subdirectories not existing when you try to create a new file

micha21:11:59

you will want to do something like (io/make-parents (io/file tmp "foo.txt"))

micha21:11:09

where io is

micha21:11:37

well in that case though i dunno

micha21:11:44

because the temp dir should exist

micha21:11:17

i don't think you're using dosh correctly there though

micha21:11:17

(dosh "bash" "-c" (str "echo FOO! > " (.getPath tmp) "/foo.txt"))

ag21:11:30

oh lemme try that!

ag21:11:11

it worked!

micha21:11:29

dosh doesn't pass the string to the shell

micha21:11:37

it does execv more or less

micha21:11:05

you want to call it with a program (`bash` in this case) and the arguments as separate strings

ag21:11:12

gotcha!

ag21:11:36

so… I have a dilemma to solve now… I have some sass files that @import stuff from npm packages . I need two tasks - one manages npm installs, second sass compilation. Independently is simple enough. But how do I make these tasks “talk” to each other? is there an example where fileset being “passed’ from one task to another?

alandipert21:11:02

@ag the preferred way is for the task to add a manifest/metadata file of some kind to the fileset, for subsequent tasks to find/consume

flyboarder21:11:14

@ag I made a task for installing npm things degree9/boot-npm

ag21:11:24

@flyboarder yeah, as I said npm install by itself a trivial problem. but in my sass file let’s say I have something like @import “./node_modules/font-awesome/scss/font-awesome”. How do I make two independent tasks that deal with the same fileset?

ag21:11:15

how do I run npm task and then make node_modules available to be consumed in sass-task?

ag21:11:13

@alandipert where can I read/find samples about this?

micha21:11:17

so npm has its own sort of classpath, is that it?

micha21:11:28

how does @import know what to do?

ag21:11:05

well, let’s say I just do “npm install” and copy whole “node_modules” and commit that… something like:

(deftask add-node-modules []
  (with-pre-wrap fileset
    (let [nm ( "node_modules")]
      (when-not (and (.exists nm) (.isDirectory nm))
        (dosh "npm" "install"))
      (-> fileset
        (add-resource ( ".") :include #{#"^node_modules/"})
        commit!))))

ag21:11:58

this sorta “returns” a fileset innit?

ag21:11:20

so if I have that and this:

(deftask sassc []
  (with-pre-wrap fileset
    (let [tmp (.getPath (tmp-dir!))]
      (let [main-sass (->> fileset input-files (by-name ["main.sass"])
                        first tmp-file .getPath)
            out (str tmp "/css/main.css")]
        
        (.mkdir (java.io.File. (str tmp "/css")))
        (dosh "bash" "-c" (str "sassc " main-sass " > " out))

        (-> fileset
          (add-resource tmp)
          commit!)))))
how can I make use of fileset of the first in the second?

ag21:11:39

because if main.sass contains a line that imports something ouf of node_modules - sassc task would fail with File to import not found or unreadable:

ag22:11:51

oh… I think I get it now… if I just (boot (comp (first-task) (second-task)) anything that first task commits into fileset would be available in second-task

ag22:11:25

what’s idiomatic way of throwing a message that certain task should be always called in composition with another task?

micha22:11:06

you can use boot.util/warn for example

flyboarder22:11:11

@ag the npm task i use copies the whole folder to the fileset so once everything is installed you can use sift task to filter out the things you don't want

flyboarder22:11:19

@micha is there a way for tasks to receive metadata about the pipeline? Like to know if the reload task is being used?

ag22:11:47

what’s the best way to find out if the fileset includes a certain directory?

ag22:11:13

boot.core/by-path?

micha22:11:18

@ag the fileset is like git, it doesn't really care about directories

micha22:11:30

only files

micha22:11:44

so you can't have an empty directory in the fileset, for instance

micha22:11:02

@flyboarder usually you want to avoid directly coupling two tasks

ag23:11:35

ehmm.. guys… this is probably something totally unrelated to boot. but I haven’t seen this in lein-figwheel. I’m using pandeiro.boot-http and the initial load of first page is pretty slow. And it prints bunch of messages in nrepl-server buffer