如何在TypeScript中使用Azure CLI“ az acr”命令

问题描述 投票:0回答:2

我正在尝试创建自定义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,所以请原谅我的无能]

typescript tfs azure-devops
2个回答
0
投票

尝试使用模板字符串,如下所示:

`az acr ${repository} show-manifests --name ${registry} --repository ${repository} --orderby time_asc -o tsv`

0
投票

您似乎正在尝试运行shell命令,因此使用bash脚本可能更合适。

但是,如果要在节点上使用TypeScript,则在节点中需要ts-nodechild_process API。

这是一个使用JavaScript(因此不需要ts-node)但使用TypeScript类型检查的示例:child_process

© www.soinside.com 2019 - 2024. All rights reserved.