我正在尝试创建自定义Azure DevOps Server 2019
任务。对于Windows,我已经创建了.ps1
脚本,但是在Linux上遇到了麻烦-为此,我选择用TypeScript
编写,因为我真的不喜欢用js
编写。脚本非常简单]
let registry = "Registry3";//argv[1]
let timestamp = "2020-01-01";//argv[2]
let repository = "hello-world";//to be looped
az acr repository show-manifests --name registry --repository repository --orderby time_asc -o tsv;
尝试用tsc file.ts
编译时出现以下错误
Clean-ACR.ts:54:6 - error TS1005: ';' expected.
54 az acr repository show-manifests --name registry --repository repository --orderby time_asc -o tsv;
~~~
依此类推,从“ acr”到行尾的每个单词。显然,TypeScript不处理此行,因为它的语法不正确。但是我应该如何使用该命令?我用TypeScript完成了newby,所以请原谅我的无能]
尝试使用模板字符串,如下所示:
`az acr ${repository} show-manifests --name ${registry} --repository ${repository} --orderby time_asc -o tsv`
您似乎正在尝试运行shell命令,因此使用bash脚本可能更合适。
但是,如果要在节点上使用TypeScript,则在节点中需要ts-node和child_process
API。
这是一个使用JavaScript(因此不需要ts-node)但使用TypeScript类型检查的示例:child_process