Skip to content

Commit

Permalink
feat: provide bundled API (#49)
Browse files Browse the repository at this point in the history
* 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 <raisinten@gmail.com>

* fixup! test: bump timeout value from 60000 to 65000

Signed-off-by: Darshan Sen <raisinten@gmail.com>

* fixup! test: bump timeout value from 65000 to 70000

Signed-off-by: Darshan Sen <raisinten@gmail.com>

* fixup! fix: --output-api-header handling

Signed-off-by: Darshan Sen <raisinten@gmail.com>

* fixup! refactor: bundling and copying to dist logic

Signed-off-by: Darshan Sen <raisinten@gmail.com>

* fixup! chore: Error -> TypeError

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

Signed-off-by: Darshan Sen <raisinten@gmail.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
  • Loading branch information
RaisinTen and dsanders11 authored Oct 12, 2022
1 parent 4fe587c commit 52502e6
Show file tree
Hide file tree
Showing 9 changed files with 483 additions and 2,055 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 52502e6

Please sign in to comment.