-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
17 additions
and
14 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
14 changes: 14 additions & 0 deletions
14
packages/sc-project-initializer/commands/init/src/utils.ts
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,7 +1,21 @@ | ||
import * as dotenv from 'dotenv'; | ||
import { readFileSync } from 'fs'; | ||
import { fileURLToPath } from 'url'; | ||
import path from 'path'; | ||
|
||
dotenv.config(); | ||
|
||
export function getEnvVariable(key: string): string { | ||
const value = process.env[key]; | ||
if (!value) { | ||
throw new Error(`Missing ${key} in .env file`); | ||
} | ||
return value; | ||
} | ||
|
||
export function getScByteCode(folderName: string, fileName: string): Buffer { | ||
// Obtain the current file name and directory paths | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(path.dirname(__filename)); | ||
return readFileSync(path.join(__dirname, folderName, fileName)); | ||
} |