From 3f302dbde2a9ca174d7b5ec87be04b9dc78345ea Mon Sep 17 00:00:00 2001 From: ikatyang Date: Sat, 15 Jul 2017 23:55:45 +0800 Subject: [PATCH] chore(travis): set cron event --- .travis.yml | 3 +++ README.md | 13 ------------- package.json | 3 ++- scripts/generate.ts | 11 +++++++++++ 4 files changed, 16 insertions(+), 14 deletions(-) delete mode 100644 README.md create mode 100644 scripts/generate.ts diff --git a/.travis.yml b/.travis.yml index 3b09c6f..6d81cf4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,9 @@ script: - yarn run lint - yarn run test -- --verbose --coverage +after_success: +- if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then yarn run generate; fi + cache: yarn: true directories: diff --git a/README.md b/README.md deleted file mode 100644 index 9de6c15..0000000 --- a/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# emoji-cheat-sheet-generator - -Setup - -```sh -npm install -``` - -Generate Cheat Sheet - -```sh -npm run generate -``` diff --git a/package.json b/package.json index e9904d4..a401474 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "repository": "https://github.com/ikatyang/emoji-cheat-sheet/tree/generator", "scripts": { "lint": "tslint -p ./tsconfig.json", - "test": "jest -c ./jest.json" + "test": "jest -c ./jest.json", + "generate": "ts-node ./scripts/generate.ts ./README.md" }, "dependencies": { "cheerio": "^0.22.0", diff --git a/scripts/generate.ts b/scripts/generate.ts new file mode 100644 index 0000000..6fffd84 --- /dev/null +++ b/scripts/generate.ts @@ -0,0 +1,11 @@ +import * as fs from 'fs'; +import {create_cheat_sheet} from '../src/create-cheat-sheet'; + +const output_filename = process.argv[2]; +if (output_filename === undefined) { + throw new Error(`Usage ts-node path/to/generate.ts path/to/output.md`); +} + +create_cheat_sheet().then(cheat_sheet => { + fs.writeFileSync(output_filename, cheat_sheet, 'utf8'); +});