Skip to content

Commit

Permalink
start cli & npm package
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyProgrammist committed Jan 16, 2024
1 parent 4bf7e50 commit d636070
Show file tree
Hide file tree
Showing 11 changed files with 464 additions and 136 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ typings/
## ======

dist/
build/
24 changes: 0 additions & 24 deletions generate_all.ts

This file was deleted.

11 changes: 11 additions & 0 deletions generate_tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import path from 'path'
import util from 'util'
import { generateCode } from './src/main'

function genCodeForTest(name: string) {
const fixturesDir = path.resolve(__dirname, 'test')
generateCode(path.resolve(fixturesDir, 'tlb', name + '.tlb'), 'test/generated_files/generated_' + name + '.ts')
}

genCodeForTest('block')
genCodeForTest('test')
1 change: 0 additions & 1 deletion index.ts

This file was deleted.

3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: [
"**/?(*.)+(spec|test).[j]s?(x)"
]
};
24 changes: 24 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node
import meow from 'meow';
import { generateCode } from './src/main';

const cli = meow(`
Usage
$ foo <tlbpath>
Options
--output, -o Output file, defult = tlbpath + ".tst"
`, {
flags: {
output: {
type: 'string',
shortFlag: 'o'
}
}
});


let input = cli.input.at(0)
if (input) {
generateCode(input, input + ".ts");
}
Loading

0 comments on commit d636070

Please sign in to comment.