write gulp tasks in powershell
npm install posh-gulpEver wanted to implement your gulp task directly with powershell?
Tasks
-----
js
const gulp = require('gulp');
const pulp = require('posh-gulp');
gulp.task('build', (cb) => {
console.log('building');
cb();
});
pulp(gulp, './gulpfile.ps1');
gulp.task('default', gulp.series('posh:simple'));
`
$3
`powershell
Import-Module ./path-to-posh-gulp/Gulp
Add-Task "posh:empty"
Add-Task "posh:simple" ("build", "posh:empty") {
Write-Host 'simple powershell task'
}
Publish-Tasks $args
`
$3
`
Importing Tasks ./gulpfile.ps1
Using gulpfile [...]/gulpfile.js
Starting 'build'...
building
Finished 'build'
Starting 'posh:empty'...
Finished 'posh:empty'
Starting 'posh:simple'...
simple powershell task
Finished 'posh:simple'
Starting 'default'...
Finished 'default'
`
Development
===========
Run powershell tests with pester (choco install):
`powershell
Invoke-Pester
`
Streaming Output (Optional)
---------------------------
Set the environment variable POSH_GULP_STREAMING=true to stream each line from a PowerShell task as it is
produced instead of waiting for the task to finish. This is useful for long running tasks (e.g. docker builds)
to observe progress in real time.
Example quick test:
`powershell
Add-Task "stream:test" @() {
for ($i=1; $i -le 3; $i++) { Write-Host "stream-line-$i"; Start-Sleep -Seconds 1 }
}
Publish-Tasks $args
run with
$env:POSH_GULP_STREAMING='true'; npx gulp stream:test
`
If POSH_GULP_STREAMING is not set or is anything other than true`, the legacy buffered output behaviour