You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-3Lines changed: 33 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,8 +23,20 @@ This repository itself can be cloned and edited to your needs.
23
23
```
24
24
git clone git@github.com:mapbox/node-cpp-skel.git
25
25
cd node-cpp-skel
26
-
make # build binaries
26
+
27
+
# Build binaries. This looks to see if there were changes in the C++ code. This does not reinstall deps.
28
+
make
29
+
30
+
# Run tests
27
31
make test
32
+
33
+
# Cleans your current builds and removes potential cache
34
+
make clean
35
+
36
+
# Cleans everything, including the things you download from the network in order to compile (ex: npm packages).
37
+
# This is useful if you want to nuke everything and start from scratch.
38
+
# For example, it's super useful for making sure everything works for Travis, production, someone else's machine, etc
39
+
make disclean
28
40
```
29
41
30
42
Note: by default the build errors on compiler warnings. To disable this do:
@@ -33,6 +45,7 @@ Note: by default the build errors on compiler warnings. To disable this do:
33
45
WERROR=false make
34
46
```
35
47
48
+
To build from scratch
36
49
37
50
# Code coverage
38
51
@@ -53,13 +66,30 @@ If you're developing on macOS and have Xcode installed, you can also type `make
53
66
54
67
# Usage
55
68
69
+
### Standalone sync function
56
70
```javascript
57
-
var HelloWorld =require('./path/to/lib/index.js');
58
-
varHW=newHelloWorld();
71
+
varmodule=require('./path/to/lib/index.js');
72
+
var check =module.hello();
73
+
74
+
console.log(check); // => world
75
+
```
76
+
77
+
### Object
78
+
```javascript
79
+
varmodule=require('./path/to/lib/index.js');
80
+
varHW=newmodule.HelloWorld();
59
81
var hi =HW.wave();
82
+
60
83
console.log(hi); // => howdy world!
61
84
```
62
85
86
+
# Add Custom Code
87
+
`node-cpp-skel` was designed to make adding custom code simple and scalable, to form to whatever use-case you may need. Here's how!
88
+
89
+
- Create a dir in `./src` to hold your custom code. See `./src/standalone` as an example.
90
+
- Add your new method or class to `./src/module.cpp`
91
+
- Add your new file-to-be-compiled to the list of target sources in `./binding.gyp`
92
+
63
93
# Publishing Binaries
64
94
65
95
It's a good idea to publish pre-built binaries of your module if you want others to be able to install it properly on their own systems, which can very likely not have a compiler like `gcc` or `clang`. Node-pre-gyp does a lot of the heavy lifting for us (like detecting which system you are building on and deploying to s3) but you'll need a few things configured to get started.
0 commit comments