fix: template cannot be loaded from ejs file
This commit is contained in:
10
src/index.ts
10
src/index.ts
@@ -2,11 +2,12 @@ import fs from 'fs';
|
|||||||
import ejs from 'ejs';
|
import ejs from 'ejs';
|
||||||
import remark from 'remark';
|
import remark from 'remark';
|
||||||
import toc from 'remark-toc';
|
import toc from 'remark-toc';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
import GithubApi from './api';
|
import GithubApi from './api';
|
||||||
import link from './link';
|
import link from './link';
|
||||||
import git from './git';
|
import git from './git';
|
||||||
import * as core from '@actions/core';
|
import MD_TEMPLATE from './template';
|
||||||
import path from 'path';
|
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
SortedLanguageList,
|
SortedLanguageList,
|
||||||
@@ -22,10 +23,9 @@ const OUTPUT_FILENAME: string = core.getInput('output-filename') || 'README.md';
|
|||||||
const REPO_USERNAME = process.env.GITHUB_REPOSITORY?.split('/')[0];
|
const REPO_USERNAME = process.env.GITHUB_REPOSITORY?.split('/')[0];
|
||||||
const API_STARRED_URL = `${process.env.GITHUB_API_URL}/users/${REPO_USERNAME}/starred`;
|
const API_STARRED_URL = `${process.env.GITHUB_API_URL}/users/${REPO_USERNAME}/starred`;
|
||||||
|
|
||||||
const renderer = async (data: any) => {
|
const renderer = async (data: any, templateString = MD_TEMPLATE) => {
|
||||||
try {
|
try {
|
||||||
const MD_TEMPLATE = await fsp.readFile('./template.ejs', 'utf-8');
|
return ejs.render(templateString, data);
|
||||||
return ejs.render(MD_TEMPLATE, data);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.error('#renderer');
|
core.error('#renderer');
|
||||||
core.error(error);
|
core.error(error);
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# <%= username %> Awesome List [](https://github.com/sindresorhus/awesome)
|
export default `# <%= username %> Awesome List [](https://github.com/sindresorhus/awesome)
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
@@ -9,3 +9,4 @@
|
|||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<% } %>
|
<% } %>
|
||||||
|
`;
|
Reference in New Issue
Block a user