jakejs / jake

JavaScript build tool, similar to Make or Rake. Built to work with Node.js.
http://jakejs.com
Apache License 2.0
1.97k stars 190 forks source link

version 10.3.1 file task run as normal task and rebuilding everytime #364

Closed colinqq closed 4 years ago

colinqq commented 4 years ago

To see issue run using latest jake version installed with npm install -g jake: jake -f ./jakefile.js host_init_phony jake -f ./jakefile.js host_init_phony example jakefile.js

let fs = require('fs');
file('host_init_phony', function(){
  console.log('file phony start');
  fs.writeFileSync('host_init_phony', '');
  console.log('file phony end');
});
console.log('file phony loaded');
mde commented 4 years ago

Thanks very much for reporting this. I found this same issue yesterday, and am working on a fix.

mde commented 4 years ago

Fixed in https://github.com/jakejs/jake/commit/00ee2a03d568314f16e177dc00a3786a7f7e5de4 and pushed to NPM v10.3.2.

colinqq commented 4 years ago

Hi,

There is still and issue, the time it took is incorrect. it prints this when using the file is already created:

Starting 'host_init'...

Finished './host_init_phony' after 1574582400104 ms

Colin

On Sun, Nov 24, 2019 at 1:22 AM Matthew Eernisse notifications@github.com wrote:

Closed #364 https://github.com/jakejs/jake/issues/364.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jakejs/jake/issues/364?email_source=notifications&email_token=AMR2TIZEK7DA4BKFXLK6MY3QVG3LHA5CNFSM4JQBXDIKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOVBV5DFQ#event-2825638294, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMR2TIZWMGFHGQ5B2YM2NCDQVG3LHANCNFSM4JQBXDIA .

mde commented 4 years ago

I cannot reproduce what you're seeing. Is it possible you haven't updated Jake? What do you see when you run jake -v?

Here is what I get with your sample Jakefile, and current master HEAD (bin/cli.js is the jake binary):

$ ../jake/bin/cli.js host_init_phony
file phony loaded
Starting 'host_init_phony'...
file phony start
file phony end
Finished 'host_init_phony' after 2 ms
$ ../jake/bin/cli.js host_init_phony
file phony loaded

As you can see, the second time around, the only thing printed to stdout is "file phony loaded," which you are printing at the global level of the Jakefile.

colinqq commented 4 years ago

Hi Matt,

I'm not sure why this happens, and I can't create a minimal test for it. But the startTime is null at the end of a task. To fix it, move the startTime to beginning. I can see that it goes into the !this.isNeeded() if during the run.

run() { this.startTime = (new Date()).getTime(); console.log('run 1'); let val; let hasAction = typeof this.action == 'function';

if (!this.isNeeded()) {
  this.emit('skip');
  this.emit('_done');
  console.log('run 1.1');
}
else {
  console.log('run 1.2');

Colin

On Sun, Nov 24, 2019 at 8:38 PM Matthew Eernisse notifications@github.com wrote:

I cannot reproduce what you're seeing. Is it possible you haven't updated Jake? What do you see when you run jake -v?

Here is what I get with your sample Jakefile, and current master HEAD ( bin/cli.js is the jake binary):

$ ../jake/bin/cli.js host_init_phony file phony loaded Starting 'host_init_phony'... file phony start file phony end Finished 'host_init_phony' after 2 ms $ ../jake/bin/cli.js host_init_phony file phony loaded

As you can see, the second time around, the only thing printed to stdout is "file phony loaded," which you are printing at the global level of the Jakefile.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jakejs/jake/issues/364?email_source=notifications&email_token=AMR2TI52D45V7FWSR4XSQILQVLC4BA5CNFSM4JQBXDIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFAR3NQ#issuecomment-557915574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMR2TIYIQF6SG77XIDH3CVTQVLC4BANCNFSM4JQBXDIA .

colinqq commented 4 years ago

Hi Matt,

And here is the output with my console logs after moving the starttime to beggining of the function:

run 1

run 1.1

run 1

run 1.1

run 1

run 1.2

Starting 'xxx'...

starttime 1576586867285

task xxx start

did task xxx

task xxx end

*starttime *1576586867284

*endtime *1576586867287

*Finished '...Jakefile.js' after *3 ms

And here it is without the starttime (old code)

run 1run 1.1run 1run 1.1run 1run 1.2Starting 'xxx'...starttime 1576586921584task xxx startdid task xxxtask xxx endstarttime nullendtime 1576586921586Finished '...Jakefile.js' after 1576586921586 ms

On Tue, Dec 17, 2019 at 2:47 PM Colin Shribman colin@rightbound.io wrote:

Hi Matt,

I'm not sure why this happens, and I can't create a minimal test for it. But the startTime is null at the end of a task. To fix it, move the startTime to beginning. I can see that it goes into the !this.isNeeded() if during the run.

run() { this.startTime = (new Date()).getTime(); console.log('run 1'); let val; let hasAction = typeof this.action == 'function';

if (!this.isNeeded()) {
  this.emit('skip');
  this.emit('_done');
  console.log('run 1.1');
}
else {
  console.log('run 1.2');

Colin

On Sun, Nov 24, 2019 at 8:38 PM Matthew Eernisse notifications@github.com wrote:

I cannot reproduce what you're seeing. Is it possible you haven't updated Jake? What do you see when you run jake -v?

Here is what I get with your sample Jakefile, and current master HEAD ( bin/cli.js is the jake binary):

$ ../jake/bin/cli.js host_init_phony file phony loaded Starting 'host_init_phony'... file phony start file phony end Finished 'host_init_phony' after 2 ms $ ../jake/bin/cli.js host_init_phony file phony loaded

As you can see, the second time around, the only thing printed to stdout is "file phony loaded," which you are printing at the global level of the Jakefile.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jakejs/jake/issues/364?email_source=notifications&email_token=AMR2TI52D45V7FWSR4XSQILQVLC4BA5CNFSM4JQBXDIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFAR3NQ#issuecomment-557915574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMR2TIYIQF6SG77XIDH3CVTQVLC4BANCNFSM4JQBXDIA .

mde commented 4 years ago

Can you give me access to a repo of some code that exhibits this behavior? I can't fix without some sort of repro case.

colinqq commented 4 years ago

Hi,

I can let you connect remotely using chrome remote desktop to my laptop, and show you the issue and you can use my terminal to run and test out a fix.

Colin

On Fri, 17 Jan 2020, 18:13 Matthew Eernisse, notifications@github.com wrote:

Can you give me access to a repo of some code that exhibits this behavior? I can't fix without some sort of repro case.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jakejs/jake/issues/364?email_source=notifications&email_token=AMR2TIYKFBHONTUD4JT5I3DQ6HKL7A5CNFSM4JQBXDIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJIFTVI#issuecomment-575691221, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMR2TI5MZRT2HV6SHGPQMMTQ6HKL7ANCNFSM4JQBXDIA .

colinqq commented 4 years ago

Hi Matt,

https://drive.google.com/file/d/15oKoh2of8ZboGg6E8ZhcT7g-zaX5qIiN/view?usp=sharing I shared with you a zip of part of source code so you can check it out and fix jakejs so I can move from version 8.1.1 -> 10.4.3 (hopefully 10.4.4) The see the issue do the following:

You should now see the issue: Finished '/Users/colin/rb_ext/package.json' after 1579699111469 ms

Also as you can see task xxx isn't called every time which it should be. If you have any questions regarding the code talk to me.

Colin

On Fri, Jan 17, 2020 at 10:57 PM Colin Shribman colin@rightbound.io wrote:

Hi,

I can let you connect remotely using chrome remote desktop to my laptop, and show you the issue and you can use my terminal to run and test out a fix.

Colin

On Fri, 17 Jan 2020, 18:13 Matthew Eernisse, notifications@github.com wrote:

Can you give me access to a repo of some code that exhibits this behavior? I can't fix without some sort of repro case.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jakejs/jake/issues/364?email_source=notifications&email_token=AMR2TIYKFBHONTUD4JT5I3DQ6HKL7A5CNFSM4JQBXDIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJIFTVI#issuecomment-575691221, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMR2TI5MZRT2HV6SHGPQMMTQ6HKL7ANCNFSM4JQBXDIA .

mde commented 4 years ago

I thought this problem was fixed with PR https://github.com/jakejs/jake/pull/370. I've just pushed at release with this fix to NPM, v10.4.6. Can you install the latest and see if your problem is resolved?