5htp 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/utils/config.ts +41 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp",
|
|
3
3
|
"description": "5-HTP, scientifically called 5-Hydroxytryptophan, is the precursor of happiness neurotransmitter.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-cli.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -91,6 +91,6 @@
|
|
|
91
91
|
"@types/webpack-env": "^1.16.2"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
|
-
"5htp-core": "^0.0.
|
|
94
|
+
"5htp-core": "^0.0.4"
|
|
95
95
|
}
|
|
96
96
|
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*----------------------------------
|
|
2
|
+
- DEPENDANCES
|
|
3
|
+
----------------------------------*/
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
WARNING: This file SHOULDN'T import deps from the project
|
|
7
|
+
Because it's imported by the CLI, which should be independant of the app escept for loading config
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// Npm
|
|
11
|
+
import fs from 'fs-extra';
|
|
12
|
+
import yaml from 'yaml';
|
|
13
|
+
|
|
14
|
+
/*----------------------------------
|
|
15
|
+
- LOADE
|
|
16
|
+
----------------------------------*/
|
|
17
|
+
export default class ConfigParser {
|
|
18
|
+
|
|
19
|
+
public constructor(
|
|
20
|
+
public appDir: string,
|
|
21
|
+
public envName?: string
|
|
22
|
+
) {
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private loadYaml( filepath: string ) {
|
|
27
|
+
console.info(`Loading config ${filepath}`);
|
|
28
|
+
const rawConfig = fs.readFileSync(filepath, 'utf-8');
|
|
29
|
+
return yaml.parse(rawConfig);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public env() {
|
|
33
|
+
const envFile = this.appDir + '/env' + (this.envName === undefined ? '' : '.' + this.envName) + '.yaml';
|
|
34
|
+
return this.loadYaml( envFile );
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public identity() {
|
|
38
|
+
const identityFile = this.appDir + '/identity.yaml';
|
|
39
|
+
return this.loadYaml( identityFile );
|
|
40
|
+
}
|
|
41
|
+
}
|