Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add website tests #434

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/test-website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test Website Builds

on: [push, pull_request]

permissions:
contents: read

jobs:
test-website:
runs-on: ubuntu-latest
container: node
steps:
- name: Harden Runner
uses: step-security/harden-runner@55d479fb1c5bcad5a4f9099a5d9f37c8857b2845 # v2.4.1
with:
egress-policy: audit

- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- run: npx envinfo
- name: Build and Deploy
env:
NODE_OPTIONS: --openssl-legacy-provider
working-directory: ./website
run: |
npm install
npx gatsby build --prefix-paths
16 changes: 8 additions & 8 deletions website/docs/special-topics/object-function-refs.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ This example code shows how to use the `FunctionReference` class.

### src/native-addon.h

[**native-addon.h**](https://github.com/nodejs/node-addon-examples/blob/main/src/4-references-and-handle-scope/function-reference-demo/src/native-addon.h)
[**native-addon.h**](https://github.com/nodejs/node-addon-examples/blob/main/src/4-references-and-handle-scope/function-reference-demo/node-addon-api/src/native-addon.h)

`embed:src/4-references-and-handle-scope/function-reference-demo/src/native-addon.h`
`embed:src/4-references-and-handle-scope/function-reference-demo/node-addon-api/src/native-addon.h`

The `NativeAddon` C++ class has two data members that are populated in the `NativeAddon` constructor:

Expand All @@ -51,9 +51,9 @@ The `NativeAddon` C++ class has two data members that are populated in the `Nati

### src/native-addon.cc

[**native-addon.cc**](https://github.com/nodejs/node-addon-examples/blob/main/src/4-references-and-handle-scope/function-reference-demo/src/native-addon.cc)
[**native-addon.cc**](https://github.com/nodejs/node-addon-examples/blob/main/src/4-references-and-handle-scope/function-reference-demo/node-addon-api/src/native-addon.cc)

`embed:src/4-references-and-handle-scope/function-reference-demo/src/native-addon.cc`
`embed:src/4-references-and-handle-scope/function-reference-demo/node-addon-api/src/native-addon.cc`

The `NativeAddon` constructor, which is called from JavaScript, takes two function arguments. The first argument is stored as a `Napi::FunctionReference` and the second is stored as a `Napi::Function`.

Expand All @@ -65,17 +65,17 @@ The `NativeAddon` class implements two methods which can be called from JavaScri

### src/binding.cc

[**binding.cc**](https://github.com/nodejs/node-addon-examples/blob/main/src/4-references-and-handle-scope/function-reference-demo/src/binding.cc)
[**binding.cc**](https://github.com/nodejs/node-addon-examples/blob/main/src/4-references-and-handle-scope/function-reference-demo/node-addon-api/src/binding.cc)

`embed:src/4-references-and-handle-scope/function-reference-demo/src/binding.cc`
`embed:src/4-references-and-handle-scope/function-reference-demo/node-addon-api/src/binding.cc`

This is a standard `binding.cc` file:

### index.js

[**index.js**](https://github.com/nodejs/node-addon-examples/blob/main/src/4-references-and-handle-scope/function-reference-demo/index.js)
[**index.js**](https://github.com/nodejs/node-addon-examples/blob/main/src/4-references-and-handle-scope/function-reference-demo/node-addon-api/index.js)

`embed:src/4-references-and-handle-scope/function-reference-demo/index.js`
`embed:src/4-references-and-handle-scope/function-reference-demo/node-addon-api/index.js`

This JavaScript code shows the use of the `NativeAddon` class. Note that the call to the native `tryCallByStoredFunction` method fails because the data member on which it relies is not valid.

Expand Down
Loading