Launching a file using NodeJS - node.js

I was wondering how I could launch a file using nodejs. Specifically I wanted to be able to run a nodejs file and inside the code, it will open up a certain file on my local hard drive. So I want to know what is the best and safest file way to launch a file or application preferably not using exec?
Thank you

I would look at the documentation about child process. Here is the link if you would like it:
https://nodejs.org/dist/latest-v9.x/docs/api/child_process.html

Related

Server-side file system browser

I am creating a node.js web interface for an internal project in the company I am working at. The web page should allow users to select a file that is in the server memory disk for processing. I want to do something like a file browser but for the server-side file system.
I tried implementing it with jqueryfiletree but was not successful since I can not seem to put it to work. Is there any cheap trick or an useful package to do this?
Thank you in advance.
Using node.js you can get all files names in folder, using the fuction fs.readdir(). After that you can read file by name fs.readfile() and send him on client by http.
I think this is simplest solution.

Ember-cli addon read configurations

I am trying to create an ember-cli addon and I want this addon to include custom command. This part I have already done by creating a lib/commands file structure and including the script that will run the command then used includedCommands in the addon index.js.
The part I am struggling with is I want the command to be able to read a configuration file within the host applications directory. How can I do this? If I could find out the host apps absolute path I suppose I could parse a file using built in node tools but how do I find this path?
If there are better ways to accomplish this task I am all ears.
In your commands run function, you can access this.project which provides details about the project.
What you want to use is this.project.root.. it's the root directory of the project.
I have managed to solve the problem. Don't know if it is the best way. So I am able to obtain the absolute process path in node just by using process.cwd() Then I can simply append a config file name to the end of the string to get my config file absolute path.
If there are any ember-cli specific ways that I should be doing this then please let me know.

how to execute flash external code in nodejs?

I was wondering if there is a way to run flash SWF files in nodejs?
Here's what i have:
I have an SWF file which has some functions defined as externalinterface to be called in javascript like this:
$("#the-swf-element).myFunction(123);
Now i want to do this in nodejs outside of browser. Is there any way to do this?
Couldn't find any npm package for it.
All solutions are welcome, even running it in phantomjs

How can I (literally) open a file with Node?

I'm creating a command-line utility with Node that will be able to open (launch) files for the user programmatically, using the application they would use to do so by default.
After reading through the docs, I don't think fs.open() can do that.
Is there any way to do this in Node without having to pull in shell scripts?
You'd need to call a special OS-dependent program via child_process.exec() or child_process.spawn(). On Windows you'd use start, for OSX you'd use open, and for Linux you'd generally use xdg-open. You might look at using an already made module on npm for handling all these cases, such as open.

Start app on mac os directly after installation

I'd like to know if it is possible to create a dmg file which can be installed by Drag&Drop - and which starts directly after this installation without having to be called manually again.
And if this is possible, I'd like to know whether I can pass arguments to the (nodejs) process which will be started directly after the installation.
I managed to pass parameters to the process when I call it manually after the installation, but I want to run it directly.
Any help will be appreciated!
Thanks!
I solved it: Instead of creating an app and wrapping it into a dmg, I created an app and wrapped it into a pkg. For pkgs it is possible to use postinstall scripts, so I started the application through this script.

Resources