Questions tagged [shelljs]

For questions related to portable implementation of Unix shell commands for Node.js.

ShellJS is a portable (Windows/Linux/OS X) implementation of Unix on top of the

Usage

Install it using

$ npm install -g shelljs

And run scripts

$ shjs your_script_file

See also

82 questions
0
votes
1 answer

Restarting pm2 from cron/shellJS - bcrypt version error

I'm trying to set up a crontab process in Ubuntu 18.04 to periodically check on the status of pm2 and restart it if necessary. Because I'm more familiar with JavaScript, I decided to have the crontab process run a node file that gets a JSON readout…
SuperCodeBrah
  • 2,874
  • 2
  • 19
  • 33
0
votes
0 answers

How to create an environment variable in bash using Node and let the variable alive after program execution

I have a node program called xapp that runs in console. I would like xapp create a environment variable that stay alive until user close the terminal (not only while the program is running). I tried this so far: let key = 'bacon'; let MYVAR =…
alexpfx
  • 6,412
  • 12
  • 52
  • 88
0
votes
1 answer

setting custom permissions for the file and inheriting ownership from pattern folder in JS

I need to set custom permission and inherit ownership from parent directory after writing to file in JS. I'm using to shelljs to run the commands. I'm running the following to get the owner and group of the parent directory: const ownerGroup =…
Yury Stanev
  • 419
  • 1
  • 5
  • 16
0
votes
2 answers

Error message: Shelljs 0.8.3 and before are vulnerable to Command Injection

I am getting this error on my github alerts after updating my project to angular 8.0.3. It is a vulnerability with no remediation. No patched version is available. Shelljs 0.8.3 and before are vulnerable to Command Injection. Commands can be invoked…
mruanova
  • 6,351
  • 6
  • 37
  • 55
0
votes
2 answers

Error when using the NodeJs and sed to create the new Kubernetes config file

I am using the Shelljs and sed command to generate the new K8S config file shell.exec(`sed -e s%${server}%${endpoint}%g -e s%${certificate}%${cert}%g config-temp`) shell.exec("cat config-temp | tee config") Then I am checking if the K8S cluster is…
Akira
  • 273
  • 5
  • 15
0
votes
0 answers

Convert Json files to JS files

I created a Module to import all JSON files in a certain Directory and now I want to convert them into JS files and export them in a directory. I want to do that using babel plugin or shellJS recursiveReadDir(MODEL_PATH, [], function (err,…
0
votes
2 answers

How to open javascript command line with shelljs

I have been using shelljs for a project of mine and found this little problem. let shell = require('shelljs') shell.exec('js') When I execute this script, it does not open de javascript command line, instead it's like the terminal is waiting for…
0
votes
1 answer

Shelljs -- how do I represent the tmux base command "Ctrl-B" as a command?

I'm trying to use shelljs to write a script that'll help load up my local env at once while setting up my tmux panes/windows... but I don't know how to represent the Ctrl button in the command. Help? :-| example of what I thought would…
Brian Zhou
  • 574
  • 6
  • 15
0
votes
1 answer

when unit testing shelljs doesn't use my mocked filesystem but the real one

in my node.js app I have a function that should rename directory path when the user do a http put request. Anyway this function uses shelljs and when I test it manually it works but when I try to test in mocha on my mocked filesystem then shelljs…
Amit
  • 126
  • 2
  • 10
0
votes
2 answers

Unit test with sinon fake does not resolve promise

I'm learning nodejs and wrote this wrapper for a shelljs function, which in practice seems to work as intended. /** * Wrapper for Shelljs.exec to always return a promise * * @param {String} cmd - bash-compliant command string * @param …
Todd
  • 652
  • 2
  • 19
  • 37
0
votes
1 answer

Node.js absolute path

I'm trying to build a Electron app which quickly pull the machine info to the user. I'm trying to use the npm module 'shelljs' to be able to use shell script in a node environment. But Electron doesn't really support shelljs so I'm in a bit of a…
Thomas Bengtsson
  • 399
  • 2
  • 10
  • 22
0
votes
1 answer

Using nodejs to copy a folder and add a suffix to its name when folder with matching name already exists in the destination

I'm calling a Feathers JS API to copy a folder with some files. Say my folder name is 'Website1'. The normal behavior of Linux is, it appends the new folder name as 'Website1 copy' and further as 'Website1 another copy', 'Website1 3rd copy', and so…
Faizan Saiyed
  • 804
  • 3
  • 17
  • 33
0
votes
2 answers

Shelljs exec() not executing variables

Shelljs exec command doesnot take variables. I tried all possible combinations like using double quotes, single quotes, assigning $ in front of the variable etc. below is the script: #!/usr/bin/env node require('shelljs'); for(let i = 0; i <…
Indra4ev3r
  • 31
  • 5
0
votes
2 answers

Send multiple commands in series using shell.exec

I am attempting to send AT commands to a USB device in Node.js using shelljs and socat. The following (2) commands executes successfully in Terminal: $ sudo socat - /dev/ttyUSB0 AT+RESTART Note: The first command connects to the device, and the…
user3315406
0
votes
1 answer

Executing SSH with ShellJs

I have been using shelljs to execute certain set of commands. So i tried to connect to a remote ubuntu server over ssh via shelljs. This is my nodejs file. var shelljs = require('shelljs'); shelljs.exec('ssh -i [path/to/pem/file]…
Satnam Sandhu
  • 610
  • 1
  • 10
  • 25