-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): add very basic node script for CLI-based score calculation
- Loading branch information
1 parent
74da942
commit cf7772d
Showing
2 changed files
with
30 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { readFileSync } from 'node:fs' | ||
import { argv } from 'node:process' | ||
|
||
import { getState } from './src/lib/getState.ts' | ||
import { calculateScore } from './src/lib/calculateScore.ts' | ||
|
||
const path = argv[2] | ||
if (typeof path !== 'string' || path === '') { | ||
throw new Error('Path to JSON file containing save is missing!') | ||
} | ||
|
||
const content = readFileSync(path, { encoding: 'utf-8' }) | ||
const state = getState(JSON.parse(content)) | ||
const { hand, scores } = calculateScore(state) | ||
console.info(JSON.stringify({ hand, scores }, null, 2)) |