nervous-systems/cljs-lambda

Build command is silently failing when package.json is present

Closed this issue · 4 comments

No message is shown, which is not optimal. Some kind of info message would be nice.

moea commented

Thanks for reporting. IIRC lein-npm bails if package.json exists - there's probably something we could do about that.

The problem is the usage of with-out-str function, which catches the output of the npm/npm call and after its finish, it logs caught output. npm/npm internally calls leiningen.core.main/abort when something went wrong (eg. package.json is present), which simply kills the whole execution. The solution is to call it without with-out-str, which leaves log (controlled println) function out of game.

I tried this to preserve log:

(let [abort-called (volatile! false)]
    (with-redefs [main/abort #(vreset! abort-called true)]
      (log :verbose
        (with-out-str (npm/npm project "install"))))
    (when @abort-called
      (main/abort)))

which almost works... It has side-effect (due to delayed main/abort) - it deletes package.json file.

moea commented

This behaviour is pretty entrenched in lein-npm - maybe we ought to just abort with a message if package.json exists (i.e. by explicitly checking for it) and managed-deps hasn't been passed?

moea commented

Updated 0.6.3-SNAPSHOT, will release this week.