diff --git a/components/hello-world/package.json b/components/hello-world/package.json index 4512cae..87c2535 100644 --- a/components/hello-world/package.json +++ b/components/hello-world/package.json @@ -19,6 +19,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { + "c-preprocessor": "^0.2.13", "chalk": "^2.4.1", "commander": "^2.19.0", "readdirp": "^3.0.0" diff --git a/components/hello-world/src/Main.ts b/components/hello-world/src/Main.ts new file mode 100644 index 0000000..18f8e80 --- /dev/null +++ b/components/hello-world/src/Main.ts @@ -0,0 +1,15 @@ +import * as fs from "fs"; +import * as path from "path"; +import * as chalk from "chalk"; + +export function Main (subStr: string) { +// command: c-preprocessor Main.ts MainoutputFile.ts +#include "config1.js" +#if "VARIENT" == "MAC" +console.log("Mac platform string value: " + subStr); +#elif "VARIENT" == "LINUX" +console.log("Linux platform string value: " + subStr); +#else +console.log("Windows platform string value: " + subStr); +#endif +} \ No newline at end of file diff --git a/components/hello-world/src/additional.ts b/components/hello-world/src/additional.ts deleted file mode 100644 index e69de29..0000000 diff --git a/components/hello-world/src/config1.js b/components/hello-world/src/config1.js new file mode 100644 index 0000000..0e680c7 --- /dev/null +++ b/components/hello-world/src/config1.js @@ -0,0 +1,6 @@ +#define MY_CONST true +#define variable1 1 +#define variable2 4 +//#define MY_CONST2 House +#define MY_CONST3 42 +#define VARIENT LINUX \ No newline at end of file diff --git a/components/hello-world/src/index.js b/components/hello-world/src/index.js index a2880bd..d9a8a73 100644 --- a/components/hello-world/src/index.js +++ b/components/hello-world/src/index.js @@ -3,6 +3,7 @@ const path = require("path"); const chalk=require("chalk"); const rimraf = require("rimraf"); const commander = require("commander"); +const main = require("./Main").Main; const program = new commander.Command("Hello World NPM CLI"); program.option("--displayMsg"); @@ -17,4 +18,28 @@ if (program.green) { if (program.red) { console.log(chalk.red("Message was configured to show in red color.")); -} \ No newline at end of file +} + +// ** c-preprocess ** +// 1st globally install this package +//command: c-preprocessor index.js outputFile.js +//------------------------------------------------- +// #include "config1.js" + +// #if variable1 + variable2 == 5 && defined(MY_CONST) +// console("Multi-condition test") +// #elif "MY_CONST2" == "House" +// console.log("Equality Check Pass") +// #else +// console.log("Default Statement!") +// #endif + +// #ifndef MY_CONST3 +// console.log("Var is not defined!") +// #else +// console.log("Var is defined!") +// #endif +//------------------------------------------------- + +var str = "Hello World"; +main(str);