Skip to content

Commit

Permalink
feat: provide bundled API
Browse files Browse the repository at this point in the history
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 <raisinten@gmail.com>
  • Loading branch information
RaisinTen committed Oct 10, 2022
1 parent 4fe587c commit 5b4f6b4
Show file tree
Hide file tree
Showing 9 changed files with 481 additions and 2,053 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ endif()
add_subdirectory(vendor/lief)

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

if(MSVC)
set_property(TARGET postject PROPERTY LINK_FLAGS /NODEFAULTLIB:MSVCRT)
Expand Down
10 changes: 10 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ npm i -g postject

## Usage

### Command line utility

```sh
$ postject -h
Usage: postject [options] <filename> <resource_name> <resource>
Expand All @@ -32,6 +34,14 @@ Options:
-h, --help display help for command
```
### Using Programatically
```js
const { inject } = require('postject');

await inject('a.out', 'lol', Buffer.from('Hello, world!'));
```
## Building
### Prerequisites
Expand Down
Loading

0 comments on commit 5b4f6b4

Please sign in to comment.