[nodejs] fs.writeFileSync and fs.inlinkSyn to a particular file not working

2017-06-19 Thread Emmanuel Amodu
I am trying to update a certain file with the writeFileSync  method but it 
is not working

"negotiate": function(menu){
if (menu) {
//this would be changed later to the appropraite request
//get url from menu
//getting task list quesions
menu = fs.readFileSync(rootPath + menu.output, 'utf8');
menu = JSON.parse(menu);
}
var userData = fs.readFileSync(this.pathToUserTable(), 'utf8');
userData = JSON.parse(userData);

userData = this.updateUserDataForNegotiate(userData, menu);
//fs.unlinkSync(this.pathToUserTable());//this not working 
fs.writeFileSync(this.pathToUserTable(), JSON.stringify(userData));//this 
not working 
fs.writeFileSync(rootPath + "/database/users/test.json", JSON.stringify(
userData));//this is working
this.res.send(menu);
},

This is very weird and frustrating, I have been trying for hours to get it 
to work. Pls I need help.



-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/a0825def-229d-4760-94c2-6a56875a51d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: ShelljsExec return \n on parsing

2017-06-19 Thread Zlatko
You can try a simple parseFloat:

const balance = parseFloat(data);

Just make sure you get an actual number.

On Sunday, June 18, 2017 at 7:12:46 AM UTC+2, Woukaine Beyond wrote:
>
> Hi,
>
> I use this script for get my bitcoin balance : 
>
> app.get('/GET/MY/BITCOIN/BALANCE', function (req, res) {
> if( isConnected(req) == true)
> {
> var child = exec('cd /home/rpcdaemon/wallets/bitcoin-0.14.1/bin; 
> ./bitcoin-cli getbalance ' + req.params.account, {async:true});
> child.stdout.on('data', function(data) {
> var bitcoin_balance = data;
> res.send({"success":true, bitcoin_balance:bitcoin_balance});
> });
> }
> });
>
> the variable "bitcoin_balance" == 0.0 but return 0.0\n to my 
> json...
>
> How to fix it ? Thx !
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/78d2a968-11b2-4cf9-bb86-04dce51df497%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Embedding nodejs and addon in the same binary (C++).

2017-06-19 Thread Piotr Szczepanski
Hello,

I've started doing a simple project, but I've hit a brick-wall on how to 
achieve certain "effects"

First things first. I have a Win32 application that embeds nodejs 
enviroment, for simplicity, let's say I have this simple code responsible 
for embedding node:

int main(int argc, char* argv[])
> {
> node::Start(argc, argv);
> return 0;
> }


When run, it works as expected.

Now, I wanted to add some addons for it. Let's say I have written a simple 
addon:

#include 
> NAN_METHOD(hello)
> {
> info.GetReturnValue().Set(Nan::New("hello world!").ToLocalChecked());
> }
> NAN_MODULE_INIT(Init)
> {
> NAN_EXPORT(target, hello);
> }
> NODE_MODULE(addon, Init) 


If I compile it as external module and execute var addon = 
require('./addon.node') everything works great, but I want to have this 
already embedded when nodejs starts.

I know this is possible as nodejs itself does this, but I haven't yet 
figured out how to do this. Does anyone have an idea how do I combine the 
two c++ files into one binary that will work without the need to import the 
plugin?

With best regards,
Piotr

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/c037730f-b6ce-4d6a-8e43-42758b08b526%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.