Skip to content

Instantly share code, notes, and snippets.

@tathamoddie
Created June 21, 2010 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tathamoddie/446266 to your computer and use it in GitHub Desktop.
Save tathamoddie/446266 to your computer and use it in GitHub Desktop.
Web asset merging with PowerShell
@echo off
setlocal
set tempscript=%temp%\%~n0.%random%.ps1
echo $ErrorActionPreference="Stop" >"%tempscript%"
echo ^& "%~dpn0.ps1" %* >>"%tempscript%"
powershell.exe -command "& \"%tempscript%\""
set errlvl=%ERRORLEVEL%
del "%tempscript%"
exit /b %errlvl%
#requires -Version 2
param (
[switch]$Verbose = $false
)
$ErrorActionPreference = "Stop"
if ($Verbose) { $VerbosePreference = "Continue" }
$PSScriptFilePath = (Get-Item $MyInvocation.MyCommand.Path).FullName
$PSScriptRoot = Split-Path -Path $PSScriptFilePath -Parent
$SearchPath = $PSScriptRoot
Write-Verbose "Searching recursively for *.set in $SearchPath"
$SetDefinitions = Get-ChildItem -Path $SearchPath -Include "*.set" -Recurse
ForEach($SetDefinition in $SetDefinitions)
{
$SetOutput = Join-Path $SetDefinition.DirectoryName -ChildPath $SetDefinition.BaseName
$SetRoot = Split-Path $SetDefinition -Parent
Get-Content $SetDefinition |
%{ Get-Content -Path (Join-Path $SetRoot -ChildPath $_) } |
Set-Content -Path $SetOutput
}
yui/core-library.js
some-dependency.js
some-other-dependency.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment