Skip to content

Commit

Permalink
feat(template): adds templates
Browse files Browse the repository at this point in the history
if an `TEMPLATE.ejs` file is found in the repo it will be used for rendering

closes #14
  • Loading branch information
simonecorsi committed Apr 13, 2022
1 parent 3c630ec commit 791de9a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 28 deletions.
31 changes: 10 additions & 21 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
## <small>1.0.45 (2022-01-17)</small>

* build(deps): bump shelljs from 0.8.4 to 0.8.5 ([1da350a](https://github.com/simonecorsi/mawesome/commit/1da350a))


- build(deps): bump shelljs from 0.8.4 to 0.8.5 ([1da350a](https://github.com/simonecorsi/mawesome/commit/1da350a))

## <small>1.0.44 (2021-10-26)</small>

* chore(release): v1.0.44 ([6ffe17f](https://github.com/simonecorsi/mawesome/commit/6ffe17f))
* feat: git add multiple files at once ([4aef61f](https://github.com/simonecorsi/mawesome/commit/4aef61f))


- chore(release): v1.0.44 ([6ffe17f](https://github.com/simonecorsi/mawesome/commit/6ffe17f))
- feat: git add multiple files at once ([4aef61f](https://github.com/simonecorsi/mawesome/commit/4aef61f))

## <small>1.0.43 (2021-10-15)</small>

* chore(release): v1.0.43 ([5e0ef82](https://github.com/simonecorsi/mawesome/commit/5e0ef82))
* feat: reduce json output size ([94635fe](https://github.com/simonecorsi/mawesome/commit/94635fe))


- chore(release): v1.0.43 ([5e0ef82](https://github.com/simonecorsi/mawesome/commit/5e0ef82))
- feat: reduce json output size ([94635fe](https://github.com/simonecorsi/mawesome/commit/94635fe))

## <small>1.0.42 (2021-10-14)</small>

* chore(release): v1.0.42 ([5b36813](https://github.com/simonecorsi/mawesome/commit/5b36813))
* fix(paginator): last page now correctly matches rex ([dcf9898](https://github.com/simonecorsi/mawesome/commit/dcf9898))


- chore(release): v1.0.42 ([5b36813](https://github.com/simonecorsi/mawesome/commit/5b36813))
- fix(paginator): last page now correctly matches rex ([dcf9898](https://github.com/simonecorsi/mawesome/commit/dcf9898))

## <small>1.0.41 (2021-10-14)</small>

* chore(release): v1.0.41 ([884fc90](https://github.com/simonecorsi/mawesome/commit/884fc90))
* test: fixs suite ([b97833f](https://github.com/simonecorsi/mawesome/commit/b97833f))
* fix: should avoid index lock ([1d6848c](https://github.com/simonecorsi/mawesome/commit/1d6848c))



- chore(release): v1.0.41 ([884fc90](https://github.com/simonecorsi/mawesome/commit/884fc90))
- test: fixs suite ([b97833f](https://github.com/simonecorsi/mawesome/commit/b97833f))
- fix: should avoid index lock ([1d6848c](https://github.com/simonecorsi/mawesome/commit/1d6848c))
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 20 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as core from '@actions/core';
import { readdir, readFile } from 'fs/promises';

import {
renderer,
Expand Down Expand Up @@ -27,11 +28,25 @@ export async function main(): Promise<any> {
{}
);

const rendered = await renderer({
username: REPO_USERNAME,
stars: Object.entries(sortedByLanguages),
updatedAt: Date.now(),
});
// get template if found in the repo
let template;
try {
const dir = await readdir('./');
core.info(dir.join('\n'));
template = await readFile('TEMPLATE.ejs', 'utf8');
core.info(template);
} catch {
core.warning("Couldn't find template file, using default");
}

const rendered = await renderer(
{
username: REPO_USERNAME,
stars: Object.entries(sortedByLanguages),
updatedAt: Date.now(),
},
template
);

const markdown: string = await generateMd(rendered);

Expand Down

0 comments on commit 791de9a

Please sign in to comment.