typescript - 将值从 typescript 函数导入到 shell 脚本
问题描述
const printKeyAndValue = (objVal: any) => {
for (const key of Object.keys(objVal)){
console.log(key);
console.log(objVal[key]);
}
};
const obj = {
"int": {
"name": "internal",
"products": {
"test": "Internal Test from Actions"
}
},
"tst": {
"name": "test",
"products": {
"action": "Test Actions"
}
}
};
//printKeyAndValue(obj.tst.products);
const thingtolookup = "Test Actions"
var matchingkey = ""
for (const segment in obj) {
console.log("Segment: " + segment);
const segmentobj = obj[segment];
console.log("Segment: " + segmentobj["name"]);
const productsobj = segmentobj["products"];
for(const product in productsobj) {
console.log("Product: " + product);
console.log("Value: " + productsobj[product]);
if(thingtolookup == productsobj[product]) {
matchingkey = segment + "-" + product;
}
}
}
const found = !(matchingkey == "");
console.log("Found? " + found);
console.log("Found: " + matchingkey);
上面的代码是从作业中的 Github 操作中调用的。这需要传递给我正在调用 shell 脚本的另一个工作。我想将上述脚本中的“matchingkey”值传递给 shell 脚本并使用它。
解决方案
推荐阅读
- xml - 将xml转换为jsonx格式
- email - 如何设置电子邮件的“MAIL FROM”标头?
- node.js - 模块 vs 类 vs 对象字面量
- html - 如何将日期输入占位符与Firefox的中心对齐
- html - 向 WKWebView 添加自定义字体不起作用
- github - GitHub Gist API 速率限制何时重置?
- java - 向 WebSocketHandlerRegistry 添加多个处理程序
- r - 如何在最近的日期合并 2 个 zoo/data.frame 对象?
- windows - htaccess AuthType 此处不允许,500 内部服务器错误
- python - 如何在 python 中进行多次切片而不更改 np.array 本身以节省内存?