6 examples of 'nodejs run bash command' in JavaScript

Every line of 'nodejs run bash command' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
36function generateBashCommand(scriptFile) {
37 return 'bash ' + __dirname + '/../scripts/mac/' + scriptFile + '.sh';
38}
7function runWithShjs(name) {
8 // prefix with 'node ' for Windows, don't prefix for unix
9 const binPath = path.resolve(__dirname, '../bin/shjs');
10 const execPath = process.platform === 'win32'
11 ? `${JSON.stringify(process.execPath)} `
12 : '';
13 const script = path.resolve(__dirname, 'resources', 'shjs', name);
14 return shell.exec(`${execPath}${binPath} ${script}`, { silent: true });
15}
108private async sh(cmd: string) {
109 return new Promise((resolve, reject) => {
110 process.exec(cmd, (err, stdout, stderr) => {
111 if (err) {
112 console.log(err);
113 reject({ err });
114 } else {
115 resolve(stdout);
116 }
117 });
118 });
119}
46runCommand(hookScript) {
47 console.log(`Running command: ${hookScript}`);
48 return execSync(hookScript, { stdio: [this.stdin, this.stdout, this.stderr] });
49}
3export function getZshCommand () {
4 this.checkProject()
5 const { project, server, type, run } = this
6 const command = `docker ${type.socket} run -t -i ${run.tag} /bin/zsh`
7 return [
8 `cd ${server.dir}`,
9 command,
10 `cd ${project.dir}`
11 ].join(' && ')
12}
6function run(command, commandScript) {
7
8 return new Promise((resolve) => {
9
10 exec(commandScript, (error, stdout, stderr) => {
11
12 if (stderr && error) {
13 resolve(null, stderr.replace(/\r?\n|\r/, '').trim());
14 } else {
15 resolve(stdout.replace(/\r?\n|\r/, '').trim(), null);
16 }
17
18 });
19 });
20}

Related snippets