From 69791951ab2b45ccf15970ec0eb0cb72342d7064 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Thu, 1 Oct 2020 20:25:16 +0300 Subject: [PATCH] Add script in bin/ and building of .ts files --- .gitignore | 3 ++- bin/make-workout.js | 17 +++++++++++++++++ package.json | 6 +++++- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100755 bin/make-workout.js diff --git a/.gitignore b/.gitignore index 72f1ef2..682c87a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ -yarn-error.log \ No newline at end of file +yarn-error.log +dist/ \ No newline at end of file diff --git a/bin/make-workout.js b/bin/make-workout.js new file mode 100755 index 0000000..8211972 --- /dev/null +++ b/bin/make-workout.js @@ -0,0 +1,17 @@ +#!/usr/bin/env node +/* eslint-disable @typescript-eslint/no-var-requires */ +const fs = require("fs"); +const { generateZwo } = require("../dist/generateZwo"); +const { parse } = require("../dist/parser"); +const { stats } = require("../dist/stats"); +const { parseCliOptions } = require("../dist/parseCliOptions"); + +const opts = parseCliOptions(); + +const workout = parse(fs.readFileSync(opts.file, "utf8")); + +if (opts.stats) { + console.log(stats(workout)); +} else { + console.log(generateZwo(workout)); +} diff --git a/package.json b/package.json index 2879c33..ff6604e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,11 @@ "test:stats:1": "ts-node src/index.ts --stats examples/threshold-pushing.txt", "test:stats:2": "ts-node src/index.ts --stats examples/darth-vader.txt", "start": "ts-node src/index.ts", - "format:js": "prettier --write src/" + "format:js": "prettier --write src/", + "build": "tsc" + }, + "bin": { + "make-workout": "./bin/make-workout.js" }, "dependencies": { "argparse": "^2.0.1",