0

i have script test.js with content

console.log('Hello, this is EncloseJS test.');

Later will be in this file some function or other important code.

I compile it with enclose js like enclose test.js -o test.bin

Now, i need exec it in my javascript application. I tried something like require('test.bin') or eval('test.bin'); but i think, it is not right way.

Can someone hel me? Thanks.

1 Answers1

1

You could try this way:

var exec = require('child_process').exec;
var cmd = 'path/to/test.bin';

exec(cmd, function(error, stdout, stderr) 

Never tried it , but do give me a feedback

FreedomPride
  • 1,098
  • 1
  • 7
  • 30
  • Ok, test.bin was executed, but output is in stdout variable as string. But i need in test.js define custom function and then execute binary version test.bin and than run function defined in test.bin. I need to protect this function. – martinsojak Jan 12 '17 at 08:42
  • @martinsojak, basically you want to make it private, right? – FreedomPride Jan 12 '17 at 08:45
  • Yes, i want to make it privat and use function from test.bin in other javascript codes. Something like ` there is `function testFunction(){ //do something}` function in test.js ... and later use function testFunction(); in other code. – martinsojak Jan 12 '17 at 08:50