Skip to content

Commit 52502e6

Browse files
feat: provide bundled API (#49)
* feat: provide bundled API Node.js core doesn't support relative require calls, so this change provides a bundles API for Postject, so that it can be used easily in Node.js. Undici too follows the same strategy. Refs: nodejs/undici#1183 Signed-off-by: Darshan Sen <[email protected]> * fixup! test: bump timeout value from 60000 to 65000 Signed-off-by: Darshan Sen <[email protected]> * fixup! test: bump timeout value from 65000 to 70000 Signed-off-by: Darshan Sen <[email protected]> * fixup! fix: --output-api-header handling Signed-off-by: Darshan Sen <[email protected]> * fixup! refactor: bundling and copying to dist logic Signed-off-by: Darshan Sen <[email protected]> * fixup! chore: Error -> TypeError Co-authored-by: David Sanders <[email protected]> Signed-off-by: Darshan Sen <[email protected]> Co-authored-by: David Sanders <[email protected]>
1 parent 4fe587c commit 52502e6

File tree

9 files changed

+483
-2055
lines changed

9 files changed

+483
-2055
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ endif()
2020
add_subdirectory(vendor/lief)
2121

2222
add_executable(postject src/postject.cpp)
23-
set_target_properties(postject PROPERTIES LINK_FLAGS "-sMODULARIZE=1 -sALLOW_MEMORY_GROWTH -sINITIAL_MEMORY=268435456 -sMAXIMUM_MEMORY=4294967296 --bind")
23+
set_target_properties(postject PROPERTIES LINK_FLAGS "-sSINGLE_FILE -sMODULARIZE=1 -sALLOW_MEMORY_GROWTH -sINITIAL_MEMORY=268435456 -sMAXIMUM_MEMORY=4294967296 --bind")
2424

2525
if(MSVC)
2626
set_property(TARGET postject PROPERTY LINK_FLAGS /NODEFAULTLIB:MSVCRT)

README.markdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ npm i -g postject
1414

1515
## Usage
1616

17+
### Command line utility
18+
1719
```sh
1820
$ postject -h
1921
Usage: postject [options] <filename> <resource_name> <resource>
@@ -32,6 +34,14 @@ Options:
3234
-h, --help display help for command
3335
```
3436
37+
### Using Programatically
38+
39+
```js
40+
const { inject } = require('postject');
41+
42+
await inject('a.out', 'lol', Buffer.from('Hello, world!'));
43+
```
44+
3545
## Building
3646
3747
### Prerequisites

0 commit comments

Comments
 (0)