Skip to content

Instantly share code, notes, and snippets.

@dfinke
Created November 28, 2012 14:00
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 dfinke/4161503 to your computer and use it in GitHub Desktop.
Save dfinke/4161503 to your computer and use it in GitHub Desktop.
Potential analogy to npm and package.json
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