pliersjs / pliers

A build tool for node.js that supports sub-project building and watching
http://pliers.js.org/
18 stars 9 forks source link

renderCss is called twice, with timeout between the two #34

Open nicholasjohn opened 10 years ago

nicholasjohn commented 10 years ago

The below example comprises of an example where updating one Stylus file (one character & saving) runs the renderCss() twice.

Extract from pliers log:

13:05:48 [pliers] Changed: public/css/components/study.styl (change)
13:05:48 [pliers] Running task: renderCss
13:05:54 [pliers] Changed: public/css/components/study.styl (change)
13:05:54 [pliers] Running task: renderCss
13:05:54 [pliers] Completed task: renderCss

Extracts from ClockSite's site/pliers.js:

pliers.filesets('css', join(__dirname, 'public', '**/*.styl'))

pliers('renderCss', function (done) {

  function compile(str, path) {
    return stylus(str)
      .use(nib())
      .set('filename', path)
      .set('warn', false)
      .set('compress', true)
      .define('versionPath', function (urlPath) {
        return new stylus.nodes.Literal('url(' + mappedVersion.versionPath(urlPath.val) + ')')
      })
  }
  var mappedVersion = versionator.createMapped(require(__dirname + '/static-file-map.json'))
    , stylesheets =
    [ join(__dirname, 'public', 'css', 'index.styl')
    , join(__dirname, 'public', 'css', 'oldie.styl')
    ]

  stylusRender(stylesheets, { compile: compile }, function (err) {
    if (err) pliers.logger.error(err.message)
    done()
  }).on('log', log)
})

pliers.watch(pliers.filesets.css, function () {
  pliers.run('renderCss', function () {
    notify('CSS rendered')
    refresh('css/index.css')
  })
})
serby commented 10 years ago

what version of pliers are you using

  pliers -V

should be 0.3.2

  pliers install -g pliers
nicholasjohn commented 10 years ago

Definitely on version 0.3.2:

➜  site git:(develop) pliers -V
0.3.2

Still getting that error:

14:18:59 [pliers] Changed: public/css/foundations/kerning.styl (change)
14:18:59 [pliers] Running task: renderCss
14:19:06 [pliers] Changed: public/css/foundations/kerning.styl (change)
14:19:06 [pliers] Running task: renderCss
14:19:13 [pliers] Completed task: renderCss
14:19:13 [pliers] Completed task: renderCss
bengourley commented 10 years ago

is this with pliers run? if so that delegates to the local version of pliers on the project.

nicholasjohn commented 10 years ago

Nope, globally and inside the project it's running 0.3.2

➜  Clock git:(develop) ✗ npm ls pliers

clock-website@0.1.0 /Users/nick/Development/Clock/Clock
└── pliers@0.3.2
nicholasjohn commented 10 years ago

Looks like the the first renderCss is activating the second in some form based on the times. Also worth noting that it is definitely rendering separately; see below for console.time() calculations:

15:45:47 [pliers] Changed: public/css/components/article.styl (change)
15:45:47 [pliers] Running task: renderCss
15:45:51 [pliers] Changed: public/css/components/article.styl (change)
15:45:51 [pliers] Running task: renderCss
renderCss: 4031ms
15:45:55 [pliers] Completed task: renderCss
renderCss: 4038ms
15:45:55 [pliers] Completed task: renderCss
serby commented 10 years ago

Is article.styl ever staged in git when then happen?

nicholasjohn commented 10 years ago

Nope, we're aware that it gets re-called upon staging.