Helpers for Node.js addons and dependency packages
Go to file
Luis Blanco afd180d7cf Fix destructive lowercase 2023-09-26 21:32:57 +04:00
.github/workflows Make install less strict 2023-01-06 20:00:38 +04:00
.vscode Update dependencies 2023-01-02 17:09:33 +04:00
conf Fix actionPack description 2023-01-04 17:52:04 +04:00
include Use gz 2023-01-04 19:23:43 +04:00
test-addon Update deps 2023-05-08 19:20:24 +04:00
utils Fix destructive lowercase 2023-09-26 21:32:57 +04:00
.eslintrc.json Adjust actions 2023-01-04 13:36:32 +04:00
.gitattributes Update deps 2022-09-24 19:02:48 +04:00
.gitignore Update deps 2023-05-08 19:20:24 +04:00
CPPLINT.cfg Update dependencies 2023-01-02 17:09:33 +04:00
LICENSE Update deps 2023-05-08 19:20:24 +04:00
README.md Use GZIP 2023-01-04 17:10:00 +04:00
index.d.ts Make install less strict 2023-01-06 20:00:38 +04:00
index.js Use object assign 2023-01-04 15:07:41 +04:00
package-lock.json Fix destructive lowercase 2023-09-26 21:32:57 +04:00
package.json Fix destructive lowercase 2023-09-26 21:32:57 +04:00

README.md

Addon Tools

This is a part of Node3D project.

NPM CodeFactor

npm i addon-tools-raub

include/addon-tools.hpp

Macro shortcuts for C++ addons using NAPI. See docs inside the folder.

Example of an addon method definition:

// hpp:
#include <addon-tools.hpp>
DBG_EXPORT JS_METHOD(doSomething);
// cpp:
DBG_EXPORT JS_METHOD(doSomething) { NAPI_ENV;
	LET_INT32_ARG(0, param0);
	std::cout << "param0: " << param0 << std::endl;
	RET_UNDEFINED;
}

index.js

JavaScript helpers for Node.js addon development. The short list of helpers:

	'getBin', 'getPlatform', 'getInclude', 'getPaths',
	'install', 'cpbin', 'download', 'read', 'write', 'copy', 'exists',
	'mkdir', 'stat', 'isDir', 'isFile', 'dirUp', 'ensuredir', 'copysafe',
	'readdir', 'subdirs', 'subfiles', 'traverse', 'copyall',
	'rmdir', 'rm', 'WritableBuffer', 'actionPack',

See the TypeScript definitions with comments.

Example for an ADDON's index.js:

	const { getBin } = require('addon-tools-raub');
	const core = require(`./${getBin()}/ADDON`); // uses the platform-specific ADDON.node

Example for binding.gyp:

	'include_dirs': [
		'<!@(node -p "require(\'addon-tools-raub\').getInclude()")',
	],

NOTE: the optional node-addon-api dependency is used by the getInclude() helper. If not found, the napi.h include path won't be a part of the returned string.

Example of cpbin usage in package.json :: scripts:

	"build-all": "cd src && node-gyp rebuild -j max --silent && node -e \"require('addon-tools-raub').cpbin('segfault')\" && cd ..",
	"build-only": "cd src && node-gyp build -j max --silent && node -e \"require('addon-tools-raub').cpbin('segfault')\" && cd ..",