Skip to content

Instantly share code, notes, and snippets.

@mobilemancer
Last active August 3, 2020 09:15
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 mobilemancer/1238cb2d31c882e8561f351a3775ccfa to your computer and use it in GitHub Desktop.
Save mobilemancer/1238cb2d31c882e8561f351a3775ccfa to your computer and use it in GitHub Desktop.
VS Code Task to Create an Aurelia Component
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
// Create a registry.ts file in the root of your modules folder
// Position in the registry.ts file before running the task
"detail": "Create the TS, HTML and CSS files for a component",
"label": "au2 create component",
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": [
"create folder",
"create ts file",
"create html file",
"create css file",
"append to registry"
],
"presentation": {
"reveal": "silent",
"panel": "shared"
},
"args": ["${input:componentName}"]
},
{
"label": "create folder",
"type": "shell",
"command": "If (!(Test-Path ${fileDirname}\\components\\${input:componentName})){md ${fileDirname}\\components\\${input:componentName}}"
},
{
"label": "create ts file",
"type": "shell",
"command": "'export class ' + ((Get-Culture).TextInfo.ToTitleCase(('${input:componentName}'.ToLower() -replace '-', ' ')) -replace ' ', '') + '{}' | Out-File -FilePath ${fileDirname}\\components\\${input:componentName}\\${input:componentName}.ts -NoClobber"
},
{
"label": "create html file",
"type": "shell",
"command": "'<div class=\"' + '${input:componentName}'.ToLower() + '\">\r\n${input:componentName}\r\n</div>' | Out-File -FilePath ${fileDirname}\\components\\${input:componentName}\\${input:componentName}.html -NoClobber"
},
{
"label": "create css file",
"type": "shell",
"command": "'.' + '${input:componentName}'.ToLower() + '{\r\n width: 100%; \r\n}' | Out-File -FilePath ${fileDirname}\\components\\${input:componentName}\\${input:componentName}.css -NoClobber"
},
{
"label": "append to registry",
"type": "shell",
"command": "'export * from \\\"./components/' + '${input:componentName}/${input:componentName}\\\";' | Out-File -FilePath ${file} -Append -NoClobber"
}
],
"inputs": [
{
"id": "componentName",
"description": "Name your component",
"default": "new-component",
"type": "promptString"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment