Giter Club home page Giter Club logo

Comments (5)

RIAEvangelist avatar RIAEvangelist commented on July 2, 2024

perhaps its the spaces? Not sure what OS you are on.

from node-cmd.

stephen-last avatar stephen-last commented on July 2, 2024

Windows.

Have you tried the multi-line example on Windows..?

from node-cmd.

RIAEvangelist avatar RIAEvangelist commented on July 2, 2024

Have you tried without the leading spaces and line breaks? Or by using the standard multi command pattern on windows. Linux, unix and mac support multiline commands by default. Perhaps windows does not? This is using only whatever is supported in the OS.

from node-cmd.

samthomson avatar samthomson commented on July 2, 2024

@stephen-last I had the same issue as you on windows. I had to modify the commands. On Windows you specify all commands on one line, separating them with ampersand.

cmd.get(
  `git clone https://github.com/RIAEvangelist/node-cmd.git & cd node-cmd & ls`, 
  function(data, err, stderr){}
)

from node-cmd.

codexu avatar codexu commented on July 2, 2024
const os = require('os');
const cmd = require('node-cmd');

function nodeCmdOs(arr) {
  return new Promise((resolve, reject) => {
    let cmdStr = '';
    if(os.type() === 'Windows_NT') {
      arr.forEach((item, index) => {
        index === 0 ? cmdStr += item : cmdStr = cmdStr + ' & ' + item
      });
    } else {
      arr.forEach((item, index) => {
        index === 0 ? cmdStr += item : cmdStr = cmdStr + '\n' + item
      });
    }
    cmd.get(cmdStr, function (err, data, stderr) {
        if (!err) {
          resolve()
        } else {
          reject(err)
        }
      }
    );
  })
}

exports = module.exports = nodeCmdOs;

from node-cmd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.