juxt / mach

A remake of make (in ClojureScript)
246 stars 21 forks source link

directory as product throws exception upon completing produce step #49

Open stijnopheide opened 7 years ago

stijnopheide commented 7 years ago

Problem

When specifying both produce and product where the product is a directory, mach fails with the following exception:

Error: EISDIR: illegal operation on a directory, open '<YOUR_DIR>'
    at Object.fs.openSync (fs.js:652:18)
    at fs.writeFileSync (fs.js:1299:33)
    at mach$core$spit_product (evalmachine.<anonymous>:1198:35)
    at evalmachine.<anonymous>:1282:24
    at evalmachine.<anonymous>:1312:43
    at mach$core$state_machine__4__auto____1 (evalmachine.<anonymous>:1333:4)
    at mach$core$state_machine__4__auto__ (evalmachine.<anonymous>:1349:46)
    at cljs$core$async$impl$ioc_helpers$run_state_machine (evalmachine.<anonymous>:90:74)
    at cljs$core$async$impl$ioc_helpers$run_state_machine_wrapped (evalmachine.<anonymous>:93:63)
    at evalmachine.<anonymous>:112:67

This is due to https://github.com/juxt/mach/blob/master/src/mach/core.cljs#L265 calling fs.writeFileSync on the directory. I'm not really sure why this post-op is necessary.

Minimal Machfile.edn to reproduce

{
  task {
    product "some-dir"
    produce #$ ["mkdir" "-p" "some-dir"]
  }
}

Work-around

You can use update! instead of produce. I'm not sure if this is intended behavior. If that's the case, I think the docs should reflect this.