读入TS文件const并使用Node JS导出

时间:2018-12-27 07:19:35

标签: node.js angular typescript

涉及NodeJS时,我无法重新启动内存

我正在尝试在TypeScript文件中读取Const

const如下所示(忽略命名)

 export const dataUi: InputField[] =

  [{
    label: "",
    isProtected: false,
    length: "12",
    isReversible: false,
    ccaType: "",
    isPanelController: false,
    isUpperCase: false,
    isRequired: false,
    order: "0",
    panel: "icaHndActnDci7Panel",
    isLov: false,
    htmlType: "text",
    form: "data",
    name: null,
    isAutoSkip: false
  }, {
    label: "",
    isProtected: false,
    length: "4",
    isReversible: false,
    ccaType: "",
    isPanelController: false,
    isUpperCase: false,
    isRequired: false,
    order: "1",
    panel: "icaHndActnDci7Panel",
    isLov: false,
    htmlType: "text",
    form: "data",
    name: null,
    isAutoSkip: false
  }];

我正在尝试获取“名称”和“面板”

并将它们导出到以下数组中:

    export const orderedDataList =[
    {
      panel: "icaTru302DataPanel",
      name: "confFunctionCode"
    }, {
      panel: "icaTru302DataPanel",
      name: "pUserDecisionW"
    }];

使用NodeJS。

同样,从TS文件中获取“名称”和“面板”并创建另一个数组。

我当前的代码如下:

    let fs = require('fs');
const settings = require('./settings.json');
const fileHeader = `
export const orderedDataList =
  [\n`;
const lastFooter = '];\n';
let fileBody = '';

fs.readdirSync(settings.projectPath).forEach(file => {
    const name = noidea;
    const panel = noidea;
    fileBody += `\t{ panel: "${panel}", \n name: "./${name}" },\n`;
    console.log(file);
});

fs.writeFile(settings.distPath, fileHeader + fileBody + lastFooter, (err) => {
    if (err) throw err;
    console.log('The file has been saved!');
});

我的问题是访问TS中的“名称”和“面板”字段 出现问题...不确定该怎么做。

在此事上,我会喜欢一些指示或指示的。

0 个答案:

没有答案