-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from naveedkhan8067/hello-world-component-fixes
Functionality updated
- Loading branch information
Showing
8 changed files
with
69 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
#define MY_CONST true | ||
#define variable1 1 | ||
#define variable2 4 | ||
//#define MY_CONST2 House | ||
#define MY_CONST3 42 | ||
#define VARIANT LINUX | ||
#define VARIANT LINUX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
#define MY_CONST true | ||
#define variable1 1 | ||
#define variable2 4 | ||
//#define MY_CONST2 House | ||
#define MY_CONST3 42 | ||
#define VARIANT MAC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
#define MY_CONST true | ||
#define variable1 1 | ||
#define variable2 4 | ||
//#define MY_CONST2 House | ||
#define MY_CONST3 42 | ||
#define VARIANT WINDOWS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,39 @@ | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import * as chalk from "chalk"; | ||
#include "../VariantConfig.js" | ||
const chalk=require("chalk"); | ||
|
||
export function Main (subStr: string): string { | ||
// command: c-preprocessor Main.ts Main.ts | ||
let moduleType; | ||
/* | ||
It provides the variant type | ||
*/ | ||
export function GetVariantType (): string { | ||
let variantType; | ||
#if "VARIANT" == "MAC" | ||
variantType = "Mac" | ||
#elif "VARIANT" == "LINUX" | ||
variantType = "Linux" | ||
#else | ||
variantType = "Windows" | ||
#endif | ||
return variantType; | ||
} | ||
|
||
/* | ||
Creates the message string | ||
*/ | ||
export function CreateMsgString (): string { | ||
const variant = GetVariantType(); | ||
const msgString = "*** " + variant + " platform --> Hello-World ***" | ||
return msgString; | ||
} | ||
|
||
#if "VARIANT" == "MAC" | ||
moduleType = "MAC" | ||
console.log("*** Mac platform -->" + subStr + " ***"); | ||
#elif "VARIANT" == "LINUX" | ||
moduleType = "LINUX" | ||
console.log("*** Linux platform -->" + subStr + " ***"); | ||
#else | ||
moduleType = "WINDOWS" | ||
console.log("*** Windows platform --> " + subStr + " ***"); | ||
#endif | ||
return moduleType; | ||
/* | ||
Display's the colored message string | ||
*/ | ||
export function DisplayMsg (messageString: string): void { | ||
#if "VARIANT" == "MAC" | ||
console.log(chalk.yellow(messageString)); | ||
#elif "VARIANT" == "LINUX" | ||
console.log(chalk.red(messageString)); | ||
#else | ||
console.log(chalk.green(messageString)); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,13 @@ | ||
const fs = require("fs"); | ||
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"); | ||
program.option("-g, --green", "Display the message in Green."); | ||
program.option("-r, --red", "Display the message in Red."); | ||
|
||
program.parse(process.argv); | ||
|
||
if (program.green) { | ||
console.log(chalk.green("Message was configured to show in green color.")); | ||
const displayMsg = require("./Main").DisplayMsg; | ||
const msgString = require("./Main").CreateMsgString; | ||
|
||
/* | ||
Main function | ||
*/ | ||
function main() { | ||
const msg = msgString(); | ||
displayMsg(msg); | ||
} | ||
|
||
if (program.red) { | ||
console.log(chalk.red("Message was configured to show in red color.")); | ||
} | ||
|
||
// ** c-preprocess ** | ||
// 1st globally install this package | ||
//command: c-preprocessor index.js outputFile.js | ||
//------------------------------------------------- | ||
// #include "VariantConfig.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 | ||
//------------------------------------------------- | ||
main(); | ||
|
||
var str = "Hello-World"; | ||
main(str); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import { expect } from "chai"; | ||
import * as rimraf from "rimraf"; | ||
import { Main } from "../Main"; | ||
#include "../../VariantConfig.js" | ||
|
||
import { expect } from "chai"; | ||
import { CreateMsgString, GetVariantType, DisplayMsg } from "../Main"; | ||
|
||
describe("Hello-World Component Tests", async () => { | ||
it("Get required module type", async () => { | ||
var msgStr = "Hello World"; | ||
const moduleType = Main(msgStr); | ||
it("verify variant and message string", async () => { | ||
const variantType = GetVariantType(); | ||
const msgString = CreateMsgString(); | ||
|
||
#if "VARIANT" == "MAC" | ||
expect(moduleType).to.equal("MAC"); | ||
expect(variantType).to.equal("Mac"); | ||
expect(msgString).to.equal("*** Mac platform --> Hello-World ***"); | ||
#elif "VARIANT" == "LINUX" | ||
expect(moduleType).to.equal("LINUX"); | ||
expect(variantType).to.equal("Linux"); | ||
expect(msgString).to.equal("*** Linux platform --> Hello-World ***"); | ||
#else | ||
expect(moduleType).to.equal("WINDOWS"); | ||
expect(variantType).to.equal("Windows"); | ||
expect(msgString).to.equal("*** Windows platform --> Hello-World ***"); | ||
#endif | ||
DisplayMsg(msgString); | ||
}); | ||
}); |