Skip to content

Commit

Permalink
v3.2.2 fix #49 fix #50.
Browse files Browse the repository at this point in the history
  • Loading branch information
nightroman committed Feb 5, 2017
1 parent 8ca4eac commit af3ea85
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 101 deletions.
22 changes: 11 additions & 11 deletions Invoke-Build-Help.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -479,31 +479,31 @@
and requires the parameter Outputs with the optional switch Partial.
Inputs are file items or paths or a script block which gets them.
Outputs are file paths or a script block which gets them.
A script block is invoked with input paths piped to it.
Automatic variables for incremental task script jobs:
Automatic variables for incremental task actions:
$Inputs - full input paths, array of strings
$Outputs - result of the evaluated parameter Outputs
$Outputs - result of the evaluated Outputs
With the switch Partial the task is processed as partial incremental.
There must be one-to-one correspondence between Inputs and Outputs.
Partial Outputs are file paths or a script block which is invoked with
input paths piped to it in order to transform them into output paths.
In addition to automatic variables $Inputs and $Outputs, inside
process{} blocks of a partial task two more variables are defined:
Partial task actions often contain "process {}" blocks.
Two more automatic variables are available for them:
$_ - current full input path
$2 - current output path
$_ - full path of an input item
$2 - corresponding output path
See also wiki topics about incremental tasks:
https://github.com/nightroman/Invoke-Build/wiki
'@
Outputs = @'
Specifies the output paths of the incremental task. It is used together
with Inputs. See Inputs for details.
Specifies the output paths of the incremental task, either directly on
task creation or as a script block invoked with the task. It is used
together with Inputs. See Inputs for more details.
'@
Partial = @'
Tells to process the incremental task as partial incremental. It is
Expand Down
26 changes: 15 additions & 11 deletions Invoke-Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ catch {
}

#.ExternalHelp Invoke-Build-Help.xml
function Get-BuildVersion {[Version]'3.2.1'}
function Get-BuildVersion {[Version]'3.2.2'}

function *My {
$_.InvocationInfo.ScriptName -match '[\\/]Invoke-Build\.ps1$'
Expand Down Expand Up @@ -358,7 +358,7 @@ function *IO {
$_
${*p}.Add($_.FullName)
}
if (!${*p}) {return 'Skipping empty input.'}
if (!${*p}) {return 2, 'Skipping empty input.'}

${private:*o} = $Task.Outputs
if ($Task.Partial) {
Expand All @@ -382,22 +382,24 @@ function *IO {
$o.Add($p)
}
}
if ($i) {return}
if ($i) {return $null, "Out-of-date outputs: $($o.Count)/$(${*p}.Count)."}
}
else {
if (${*o} -is [scriptblock]) {
$Task.Outputs = ${*o} = & ${*o}
$Task.Outputs = ${*o} = ${*p} | & ${*o}
*SL
}
if (!${*o}) {throw 'Outputs must not be empty.'}

$Task.Inputs = ${*p}
$m = (${*i} | .{process{$_.LastWriteTime.Ticks}} | Measure-Object -Maximum).Maximum
foreach($_ in ${*o}) {
if ($m -gt [System.IO.File]::GetLastWriteTime((*FP $_)).Ticks) {return}
if ($m -gt [System.IO.File]::GetLastWriteTime((*FP $_)).Ticks) {
return $null, "Out-of-date output '$_'."
}
}
}
'Skipping up-to-date output.'
2, 'Skipping up-to-date output.'
}

function *Task {
Expand Down Expand Up @@ -427,7 +429,7 @@ function *Task {

if (${*}.Checkpoint) {*CP}
${private:*a} = $Task.Jobs
${private:*i} = [int]($null -ne $Task.Inputs)
${private:*i} = , [int]($null -ne $Task.Inputs)
$Task.Started = [DateTime]::Now
try {
. *UC Enter-BuildTask
Expand All @@ -450,17 +452,19 @@ function *Task {
continue
}

if (1 -eq ${*i}) {${*i} = *IO}
if (${*i}) {
Write-Build 8 ${*i}
if (1 -eq ${*i}[0]) {
${*i} = *IO
Write-Build 8 ${*i}[1]
}
if (${*i}[0]) {
continue
}

try {
*SL
. Enter-BuildJob
*SL
if (0 -eq ${*i}) {
if (0 -eq ${*i}[0]) {
& ${*j}
}
else {
Expand Down
5 changes: 5 additions & 0 deletions Release-Notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

# Invoke-Build Release Notes

## v3.2.2

- Incremental tasks print some more info (#49)
- Outputs block receives piped Inputs (#50)

## v3.2.1

Module help tweaks.
Expand Down
6 changes: 0 additions & 6 deletions Tests/.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@ task Dynamic {
equals $result.Tasks.Count 5
}

# Synopsis: Test incremental and partial incremental tasks.
task Incremental {
Invoke-Build . Incremental.build.ps1
}

# Synopsis: Test the default parameter.
task TestDefaultParameter {
Invoke-Build TestDefaultParameter Conditional.build.ps1
Expand Down Expand Up @@ -302,7 +297,6 @@ AllTestScripts,
Checkpoint,
Conditional,
Dynamic,
Incremental,
TestDefaultParameter,
TestExitCode,
TestSelfAlias,
Expand Down
Loading

0 comments on commit af3ea85

Please sign in to comment.