Skip to content

Memoized the result of target invocation#216

Merged
arturadib merged 1 commit intoshelljs:masterfrom
rizowski:returnResult
Aug 15, 2015
Merged

Memoized the result of target invocation#216
arturadib merged 1 commit intoshelljs:masterfrom
rizowski:returnResult

Conversation

@rizowski
Copy link
Copy Markdown
Contributor

@rizowski rizowski commented Jul 6, 2015

For a current make script I was unable to use promises as the task had previously ran.
This commit it makes it so the targets still return a result even if they have been ran. This makes it so that the promises can still be used.

For a current makescript I was unable to use promises as the task had previously ran.
This commit returns a result of the target so promises can still resolve but doesn't change
the flow of how the make file works.
@mtscout6
Copy link
Copy Markdown

mtscout6 commented Jul 6, 2015

👍

@rizowski
Copy link
Copy Markdown
Contributor Author

rizowski commented Jul 6, 2015

Looks like it is failing on node version 12 but failing to an unrelated change. I don't have permission to rerun the tests.

@mtscout6
Copy link
Copy Markdown

@arturadib Any progress on this?

arturadib added a commit that referenced this pull request Aug 15, 2015
Memoized the result of target invocation
@arturadib arturadib merged commit 409784b into shelljs:master Aug 15, 2015
@rizowski rizowski deleted the returnResult branch August 24, 2015 19:45
@danielepolencic
Copy link
Copy Markdown
Contributor

This is breaking existing functionality for me:

I used to have something like:

target.build = function () { /* write to a file */ }
target.watch = function () {
  onFileChange('*.txt', target.build);
}

With this change target.build is executed only once no matter how many times I call it from target.watch.

@mtscout6
Copy link
Copy Markdown

This would seem on par with how makefiles work. In general Makefiles only execute each target once. If you wish to invoke a function multiple times then it would be better served as a normal function that is not one of the build targets.

An alternative you could use is:

function buildAction() { /* write to a file */ }
target.build = function () { buildAction(); }
target.watch = function () {
  onFileChange('*.txt', buildAction);
}

http://stackoverflow.com/questions/17730883/how-can-i-get-a-makefile-target-to-be-called-multiple-times

@arturadib
Copy link
Copy Markdown
Collaborator

spot-on @mtscout6 thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants