Skip to content

Commit

Permalink
Fix : nest-cli build without env-template folder error fixed at #125
Browse files Browse the repository at this point in the history
Signed-off-by: ymw0407 <[email protected]>
  • Loading branch information
ymw0407 committed Oct 6, 2023
1 parent 311f50c commit 9510e4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion nest-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"assets": [
{ "include": "mail/templates/**/*", "outDir": "dist/" },
{ "include": "file/license/licenseTemplate/**", "outDir": "dist/" },
{ "include": "file/issue/default/**", "outDir": "dist/" }
{ "include": "file/issue/default/**", "outDir": "dist/" },
{ "include": "file/env-template/**", "outDir": "dist/" }
],
"watchAssets": true
}
Expand Down
7 changes: 4 additions & 3 deletions src/file/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { load } from 'js-yaml';
import { readFileSync } from 'fs';
import { readdir } from 'fs/promises';
import axios from 'axios';
import { join } from 'path';

export type file = { path: string; content: string };

Expand Down Expand Up @@ -149,12 +150,12 @@ export class FilesService {
}).path;

const filePaths: string[] = (await this.getFileList(
`./src/file/env-template${filePath}`,
join(__dirname, 'env-template', filePath),
)) as string[];

const files = filePaths.map((path) => {
const content = readFileSync(path, 'utf-8');
path = path.replace(`./src/file/env-template${filePath}/`, '');
path = path.replace(`${join(__dirname, 'env-template', filePath)}/`, '');
const file: file = { path, content };
return file;
});
Expand All @@ -164,7 +165,7 @@ export class FilesService {

getEnvTemplate = async (): Promise<envTemplateType> => {
const supportedEnv = (await load(
readFileSync('./src/file/env-template/supportedEnv.yml', {
readFileSync(join(__dirname, 'env-template', 'supportedEnv.yml'), {
encoding: 'utf-8',
}),
)) as envTemplateType;
Expand Down

0 comments on commit 9510e4e

Please sign in to comment.