Read into a TS file const export it with Node JS

ساخت وبلاگ
چکیده : I'm having trouble rebooting my memory when it comes to NodeJS I'm trying to read a Const in a TypeS... با عنوان : Read into a TS file const export it with Node JS بخوانید :

I'm having trouble rebooting my memory when it comes to NodeJS

I'm trying to read a Const in a TypeScript file

The const is as Follows (ignore the naming)

 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
  }];

I'm trying to get the "name" and "panel"

and export them into the following array:

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

using NodeJS.

As in, getting the "name" and "panel" from the TS file and creating a different array.

My current code stands is as follows:

    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!');
});

My problem is accessing the "name" and "panel" fields in the TS problem as in...Not sure how to do it.

Would love some pointers or directions in the matter, thanks in advnaced.

back soft...
ما را در سایت back soft دنبال می کنید

نویسنده : استخدام کار بازدید : 6 تاريخ : جمعه 7 دی 1397 ساعت: 17:02