mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
move files in install to js
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
|
||||
import fs from 'fs';
|
||||
|
||||
const init: Function = (): void => {
|
||||
const tempate: string = fs.readFileSync('./config.example.env', 'utf8');
|
||||
const env: string = fs.readFileSync('./config.env', 'utf8');
|
||||
const init = () => {
|
||||
const tempate = fs.readFileSync('./config.example.env', 'utf8');
|
||||
const env = fs.readFileSync('./config.env', 'utf8');
|
||||
|
||||
const linesInTemplate: Array<string> = tempate.split('\n');
|
||||
const linesInEnv: Array<string> = env.split('\n');
|
||||
const linesInTemplate = tempate.split('\n');
|
||||
const linesInEnv= env.split('\n');
|
||||
|
||||
for (const line of linesInTemplate) {
|
||||
// this is a comment, ignore.
|
||||
@@ -23,7 +23,7 @@ const init: Function = (): void => {
|
||||
// if the line is present in template but is not present in env file then add it to the env file. We assume, values in template file are default values.
|
||||
if (line.split('=').length > 0) {
|
||||
if (
|
||||
linesInEnv.filter((envLine: string) => {
|
||||
linesInEnv.filter((envLine) => {
|
||||
return (
|
||||
envLine.split('=').length > 0 &&
|
||||
envLine.split('=')[0] === line.split('=')[0]
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
import fs from 'fs';
|
||||
|
||||
const init: Function = (): void => {
|
||||
let env: string = '';
|
||||
const init = () => {
|
||||
let env = '';
|
||||
try {
|
||||
env = fs.readFileSync('./config.env', 'utf8');
|
||||
} catch (err) {
|
||||
// do nothing.
|
||||
}
|
||||
const envValToReplace: string | undefined = process.argv[2];
|
||||
const envValToReplace = process.argv[2];
|
||||
|
||||
if (!envValToReplace) {
|
||||
// eslint-disable-next-line
|
||||
@@ -17,7 +17,7 @@ const init: Function = (): void => {
|
||||
return;
|
||||
}
|
||||
|
||||
const envValToReplaceWith: string | undefined = process.argv[3];
|
||||
const envValToReplaceWith= process.argv[3];
|
||||
|
||||
if (!envValToReplaceWith) {
|
||||
// eslint-disable-next-line
|
||||
@@ -25,9 +25,9 @@ const init: Function = (): void => {
|
||||
return;
|
||||
}
|
||||
|
||||
const linesInEnv: Array<string> = env.split('\n');
|
||||
const linesToRender: Array<string> = [];
|
||||
let found: boolean = false;
|
||||
const linesInEnv = env.split('\n');
|
||||
const linesToRender = [];
|
||||
let found = false;
|
||||
|
||||
for (let line of linesInEnv) {
|
||||
// this is a comment, ignore.
|
||||
@@ -35,7 +35,7 @@ const init: Function = (): void => {
|
||||
linesToRender.push(line);
|
||||
} else {
|
||||
found = true;
|
||||
const items: Array<string> = line.split('=');
|
||||
const items = line.split('=');
|
||||
items[1] = envValToReplaceWith;
|
||||
line = items.join('=');
|
||||
linesToRender.push(line);
|
||||
Reference in New Issue
Block a user