Created
November 28, 2012 14:00
-
-
Save dfinke/4161503 to your computer and use it in GitHub Desktop.
Potential analogy to npm and package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ($key) | |
<# | |
# sample package.ps1 | |
@{ | |
start = {1..10} | |
stuff = "this is stuff" | |
} | |
#> | |
$defaultPackageName = ".\package.ps1" | |
if(Test-Path $defaultPackageName) { | |
$package = & $defaultPackageName | |
if(!$key) {$key="start"} | |
if(!$package.ContainsKey($key)) { | |
Write-Error "Cannot find $($key)" | |
Return | |
} | |
$value = $package.$key | |
switch ($value) { | |
{$_ -is [Scriptblock]} {&$_} | |
default {$_} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment