This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const style = require('ansi-styles'); | |
const express = require('express'); | |
const hello = () =>` | |
${style.green.open}Hello Green!${style.green.close} | |
${style.red.open}Hello Red!${style.red.close} | |
`; | |
const app = express(); | |
app.get('/hello', (req, res) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cppsrc/Samples/classexample.cpp b/cppsrc/Samples/classexample.cpp | |
index 8dfa3cc..834f7ea 100644 | |
--- a/cppsrc/Samples/classexample.cpp | |
+++ b/cppsrc/Samples/classexample.cpp | |
@@ -22,8 +22,17 @@ ClassExample::ClassExample(const Napi::CallbackInfo& info) : Napi::ObjectWrap<Cl | |
Napi::HandleScope scope(env); | |
int length = info.Length(); | |
- if (length != 1 || !info[0].IsNumber()) { | |
- Napi::TypeError::New(env, "Number expected").ThrowAsJavaScriptException(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/binding.gyp b/binding.gyp | |
index 2d188af..031bf18 100644 | |
--- a/binding.gyp | |
+++ b/binding.gyp | |
@@ -5,7 +5,9 @@ | |
"cflags_cc!": [ "-fno-exceptions" ], | |
"sources": [ | |
"cppsrc/main.cpp", | |
- "cppsrc/Samples/functionexample.cpp" | |
+ "cppsrc/Samples/functionexample.cpp", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* cppsrc/Samples/classexample.cpp */ | |
#include "classexample.h" | |
Napi::FunctionReference ClassExample::constructor; | |
Napi::Object ClassExample::Init(Napi::Env env, Napi::Object exports) { | |
Napi::HandleScope scope(env); | |
Napi::Function func = DefineClass(env, "ClassExample", { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* cppsrc/Samples/actualclass.cpp */ | |
#include "actualclass.h" | |
ActualClass::ActualClass(double value){ | |
this->value_ = value; | |
} | |
double ActualClass::getValue() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cppsrc/Samples/functionexample.cpp b/cppsrc/Samples/functionexample.cpp | |
index 0bd9bc2..37b7eb9 100644 | |
--- a/cppsrc/Samples/functionexample.cpp | |
+++ b/cppsrc/Samples/functionexample.cpp | |
@@ -4,13 +4,33 @@ std::string functionexample::hello(){ | |
return "Hello World"; | |
} | |
+int functionexample::add(int a, int b){ | |
+ return a + b; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/binding.gyp b/binding.gyp | |
index 23b9976..2d188af 100644 | |
--- a/binding.gyp | |
+++ b/binding.gyp | |
@@ -4,7 +4,8 @@ | |
"cflags!": [ "-fno-exceptions" ], | |
"cflags_cc!": [ "-fno-exceptions" ], | |
"sources": [ | |
- "cppsrc/main.cpp" | |
+ "cppsrc/main.cpp", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//index.js | |
const testAddon = require('./build/Release/testaddon.node'); | |
module.exports = testAddon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
*.log | |
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const childProcess = require('child_process'); | |
const process = require('process'); | |
const shelljs = require('shelljs'); | |
const startServerInNewWindow = () => { | |
const scriptFile = /^win/.test(process.platform) ? | |
'startCommand.bat' : | |
'startCommand.command'; |