Skip to content

Commit 2f3f2f7

Browse files
committed
Add publish workflow, readme, and fix typedef
1 parent 85dbbe4 commit 2f3f2f7

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

.github/workflows/publish.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Publish Package to npmjs
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
# Setup .npmrc file to publish to npm
11+
- uses: actions/setup-node@v3
12+
with:
13+
node-version: '16.x'
14+
registry-url: 'https://registry.npmjs.org'
15+
- run: yarn
16+
- run: yarn publish
17+
env:
18+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# RFIL
22

3-
Use our NPM package!
3+
Use our NPM package [here](https://www.npmjs.com/package/rfil)!
44
```bash
55
npm i rfil
66
```
77

8+
or use yarn
9+
```bash
10+
yarn add rfil
11+
```
12+
813
## Usage
914

1015
You can either use commonjs or esm.
@@ -41,6 +46,33 @@ const data = parse(buffer);
4146
console.log(data);
4247
```
4348

49+
### Exporting raw files
50+
51+
Here's an example on how to export raw files from a RFIL file.
52+
53+
```js
54+
import { parse } from 'rfil';
55+
import fs from 'node:fs';
56+
import path from 'node:path';
57+
58+
// Read a buffer from a file
59+
const buffer = fs.readFileSync('file.rfil');
60+
61+
// Parse the buffer
62+
const data = parse(buffer);
63+
64+
// Check for data
65+
if (!data.hasData()) {
66+
console.log('An error occurred: %s', data.hasError() ? data.unwrapError() : '[Unknown error]');
67+
process.exit(1);
68+
}
69+
70+
// Write files
71+
data.unwrap().data.forEach((data, index) => {
72+
fs.writeFileSync(path.join(process.cwd(), `out${index}.raw`), data.data);
73+
});
74+
```
75+
4476

4577
## RFIL File Format
4678

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.1",
44
"description": "RFIL file format for flipper",
55
"main": "dist/index.min.cjs",
6-
"types": "dist/index.d.ts",
6+
"types": "dist/index.min.d.cts",
77
"module": "dist/index.min.mjs",
88
"type": "module",
99
"repository": "https://github.com/JoshuaBrest/flipper-rfil",

0 commit comments

Comments
 (0)