Skip to content

Commit

Permalink
Merge pull request #17 from playground/build-cli
Browse files Browse the repository at this point in the history
Build cli
  • Loading branch information
playground authored Nov 13, 2021
2 parents b3319f1 + e8ac94a commit 8053408
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
13 changes: 11 additions & 2 deletions build/common/src/env.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/common/src/env.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hzn-cli",
"version": "0.1.2",
"version": "0.1.3",
"description": "Open Horizon CLI toolkit helps streamline the process of preparing node agents and perform tasks between orgs environments",
"main": "./build/index.js",
"bin": {
Expand Down Expand Up @@ -37,6 +37,7 @@
"chalk": "^4.1.2",
"clear": "^0.1.0",
"commander": "^8.2.0",
"dotenv": "^10.0.0",
"figlet": "^1.5.2",
"prompt": "^1.2.0",
"rxjs": "^7.3.0",
Expand Down
15 changes: 12 additions & 3 deletions src/common/src/env.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Observable } from 'rxjs';
import { readFileSync } from 'fs';
import { readFileSync, existsSync } from 'fs';
const cp = require('child_process'),
exec = cp.exec;
var dotenv = require('dotenv');

const pEnv = process.env;

Expand All @@ -12,6 +13,12 @@ export class Env {
hznEnv: any;
configPath: string;
constructor(env: string, configPath: string) {
if(existsSync(`${configPath}/.env-local`)) {
const localEnv = dotenv.parse(readFileSync(`${configPath}/.env-local`));
for(var i in localEnv) {
pEnv[i] = localEnv[i];
}
}
this.env = env;
this.configPath = configPath;
this.hznEnv = `${configPath}/.env-hzn.json`;
Expand All @@ -22,8 +29,10 @@ export class Env {
// console.log(process.cwd(), this.env, this.hznJson)
this.envVars = this.hznJson[this.env]['envVars'];
for(const [key, value] of Object.entries(this.envVars)) {
// @ts-ignore
pEnv[key] = value.replace(/\r?\n|\r/g, '');
if(!pEnv[key]) {
// @ts-ignore
pEnv[key] = value.replace(/\r?\n|\r/g, '');
}
// console.log(`${key}: ${pEnv[key]}`);
}
if(!this.envVars.ARCH || this.envVars.ARCH === undefined) {
Expand Down

0 comments on commit 8053408

Please sign in to comment.