How to use the shell-quote.parse function in shell-quote

To help you get started, we’ve selected a few shell-quote examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heroku / cli / packages / config / src / quote.ts View on Github external
export function parse(a: string): string {
  if (a.startsWith('"')) {
    a = a.replace(/\\n/g, '\n')
  } else if (a.startsWith("'")) {
    a = a.replace(/\\\\/g, '\\')
  }
  let parsed = shell.parse(a)
  if (parsed.length > 1) throw new Error(`Invalid token: ${a}`)
  return parsed[0]
  // return parsed[0].replace(/\\\\n/g, '\n')
}
github vesln / nixt / lib / nixt / runner.js View on Github external
Runner.prototype.execFn = function(cmd) {
  var self = this;
  var args = require('shell-quote').parse(cmd);
  var bin = args.shift(0);

  return function(fn) {
    // Allow .run('') without attempting
    if (cmd === '') { fn(undefined); return; }

    var child = spawn(bin, args, self.world);
    var stdout = '';
    var stderr = '';
    var err;

    if (self.standardInput != null) {
      child.stdin.end(self.standardInput);
    }

    if (self.world.timeout) {
github sodiumjoe / lobar / src / interactive / compute.js View on Github external
.map(input => {
    try {
      return evalChain(data, parseArgs(parse(input)));
    } catch(e) { /* */ }
  });
github zubairghori / Ultimate_todo_list / node_modules / react-dev-utils / launchEditor.js View on Github external
function guessEditor() {
  // Explicit config always wins
  if (process.env.REACT_EDITOR) {
    return shellQuote.parse(process.env.REACT_EDITOR);
  }

  // We can find out which editor is currently running by:
  // `ps x` on macOS and Linux
  // `Get-Process` on Windows
  try {
    if (process.platform === 'darwin') {
      const output = child_process.execSync('ps x').toString();
      const processNames = Object.keys(COMMON_EDITORS_OSX);
      for (let i = 0; i < processNames.length; i++) {
        const processName = processNames[i];
        if (output.indexOf(processName) !== -1) {
          return [COMMON_EDITORS_OSX[processName]];
        }
      }
    } else if (process.platform === 'win32') {
github jamesshore / automatopia / node_modules / browserify / bin / args.js View on Github external
.forEach(function (c) {
            var cmd = parseShell(c);
            b.transform(function (file) {
                var env = Object.keys(process.env).reduce(function (acc, key) {
                    acc[key] = process.env[key];
                    return acc;
                }, {});
                env.FILENAME = file;
                var ps = spawn(cmd[0], cmd.slice(1), { env: env });
                var error = '';
                ps.stderr.on('data', function (buf) { error += buf });
                
                ps.on('exit', function (code) {
                    if (code === 0) return;
                    console.error([
                        'error running source transform command: ' + c,
                        error.split('\n').join('\n  '),
                        ''
github scalameta / metals-vscode / src / getJavaOptions.ts View on Github external
function expandVariable(variable: string | undefined): string[] {
    if (variable) {
      outputChannel.appendLine("Using JAVA options set in JAVA_OPTS");
      return parse(variable).filter(
        (entry): entry is string => {
          if (typeof entry === "string") {
            return true;
          } else {
            outputChannel.appendLine(
              `Ignoring unexpected JAVA_OPTS token: ${entry}`
            );
            return false;
          }
        }
      );
    } else {
      return [];
    }
  }
  const javaOpts = expandVariable(process.env.JAVA_OPTS);
github runtools / run / core / old / 3 / src / resources / macro.js View on Github external
async $invoke(_expression, {owner} = {}) {
    const expressions = this.$expressions || [];
    let result;
    for (let expression of expressions) {
      const args = parse(expression, variable => '$' + variable);
      expression = parseCommandLineArguments(args);
      result = await this._invokeExpression(expression, {owner});
    }
    return result;
  }
github layerssss / localhostd / lib / bnb.js View on Github external
return this._lockApplication(application, () => {
      var terminal = this._terminals[application.name];
      if (terminal) return;
      var env = _.defaults({}, application.env, {
        PORT: application.port
      });
      var xs = ShellQuote.parse(application.command, env);
      var executable = xs[0];
      var args = xs.slice(1);
      var spawnCmd = executable;
      var spawnArgs = args;
      var startTime;
      var envPath = _.compact([env["PATH"], env["Path"]]).join(Path.delimiter);

      if (Os.platform() == "win32") {
        spawnCmd = env["COMSPEC"];
        spawnArgs = ["/C", ...xs];
      }

      return Promise.resolve()
        .then(() => Utility.stat(application.dir))
        .then(
          stat =>
github Starefossen / slack-jira / lib / cmd.js View on Github external
module.exports = function cmd(opts) {
  const argv = require('minimist')(parse(opts.text));
  const response_url = opts.response_url;

  return new Promise((resolve, reject) => {
    switch (argv._[0]) {
      case "find":
        const id = argv._[1];

        if (!id) {
          resolve('Usage: /jira find [id]');
        } else {
          resolve(`Locating JIRA issue ${id}...`);

          module.exports.find(id, (err, issue) => {
            let response = {};

            if (err) {

shell-quote

quote and parse shell commands

MIT
Latest version published 1 year ago

Package Health Score

74 / 100
Full package analysis

Popular shell-quote functions