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
1
vote
1 answer

Compare exec stdout with some text using shelljs

When running sh.exec('whoami') I am trying to compare the stdout but it doesn't work. What I want to do is that after running the whoami command if the results turns to be an specific user then I would like to trigger an action. When running,…
gmotzespina
  • 143
  • 7
1
vote
1 answer

shelljs execution gets stuck on DigitalOcean

I have a React web app hosted on DigitalOcean (Ubuntu 16.04). The app has an R script on the backend (node) that is invoked by shelljs (shCMD command invokes the R script. It never gets inside the exec callback): exec_full_analysis =…
Nikita Vlasenko
  • 4,004
  • 7
  • 47
  • 87
1
vote
2 answers

How to exclude some files while using shelljs to move one folder to another

I have below the structure repository: src -common - asd.ts - filter.ts -checking -hi.json -third-party -src -common -hello.ts -two.ts …
Kumaresan Sd
  • 1,399
  • 4
  • 16
  • 34
1
vote
1 answer

How to call a "JS file" by a html "button-click" and the JS file is running a bash script using shell.js

I want to connect to the "server.js" file by a html-button click. The "server.js" file is running a "bash.sh" file using shell.js Can anyone give some ideas or directions on how to proceed? button.html
Aditya Ishan
  • 507
  • 7
  • 21
1
vote
0 answers

How to run tmux cmds in nodejs

Is there any way to run tmux cmds like tmux kill-server and tmuxinator start rails_servers through nodejs. I have searched online but not able to find anything useful which can aid me to remove my error. I was trying this through shelljs npm module…
1
vote
2 answers

async issue, unable to run shelljs commands after .then

Update: I added a brief pause after writing to the file, it was only then did the shell commands work. async function testRun() { await createInsertCurlReq.createInsertCurlReq(process.argv[2]); await timeout(3000); shell.chmod("+x",…
David Trinh
  • 319
  • 1
  • 12
1
vote
0 answers

Good way to fail a jest test if it something tries to read from stdin?

I'm using shelljs and jest to test a shell script. The shell script will fallback to an interactive mode if it doesn't find certain variables it's looking for, and for most of the tests, the variables should be set and so that shouldn't happen. So,…
zanerock
  • 3,042
  • 3
  • 26
  • 35
1
vote
1 answer

Shelljs exec failed on git cherry-pick

I have a script that cherry-picks a commit using shelljs. Here is my LOC that does cherry-picking using shelljs. shell.exec('git cherry-pick commitid -X theirs'); Note: commitid = sha of commit I want to cherry-pick. shelljs is throwing the…
Srinivas Damam
  • 2,893
  • 2
  • 17
  • 26
1
vote
1 answer

shelljs "not found" error

I have below .sh file // ping.sh 01: port="$1" 02: echo "pinging http://localhost:$port/ping" 03: 04: retry=0 05: while 06: sleep 1 07: api_response=$(curl --write-out %{http_code} --silent --output /dev/null…
Mehmet Ataş
  • 11,081
  • 6
  • 51
  • 78
1
vote
0 answers

I am trying to compile code in docker container and able to create the container but unable to get any data in the callback function

Dockerfile FROM chug/ubuntu14.04x64 # Update the repository sources list RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" > /etc/apt/sources.list RUN apt-get update # RUN apt-get upgrade # Install all the languages/compilers…
1
vote
2 answers

Node Asynchronous mkdir with full path

I am currently using shell.js's mkdir -p in my node.js code which is synchronous. The '-p' is used in shell.mkdir to create a directory with a full path, something that fs.mkdir cannot do. if(fs.existsSync(archivePath + "\\" + site + "\\" + year)){…
1
vote
1 answer

Rename files and folders recursively based on regex

I have this file structure: FolderName/ [NAME]/ [NAME].controller.js [NAME].html Using Node.js I want to replace [NAME] with a variable. Here is what I've tried: const shell = require("shelljs"); shell.ls('-Rl',…
frisksitron
  • 40
  • 1
  • 6
1
vote
2 answers

shelljs performance is slow

I have been using shelljs On my super fast system I execute this: var shell = require('shelljs') const exec = require('child_process').exec console.time('shell mktemp -d') shell.exec('mktemp -d', {silent: true}) console.timeEnd('shell mktemp…
danday74
  • 52,471
  • 49
  • 232
  • 283
0
votes
0 answers

node js builtin os function find

I'm using the shelljs npm package for file traversal: var shell = require('shelljs'); cFilesOnly = function (file, idx) { return (file.includes('.c')); } excludeIrrelevantDir = function (file, idx) { return !file.includes('DDD'); } var files =…
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87
0
votes
0 answers

ShellJS not executing git command

I have been using shell js to execute a git command in a node js file as follows: if (shell.exec(`git commit -m "${messageEmoji} ${messageType} : ${commitMsg}"`).code !== 0) { console.log('Error: Git commit failed'); exit(1); …