How to use the shell-quote.quote 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 mysticatea / npm-run-all / lib / index.js View on Github external
return patterns.map(pattern => pattern.replace(ARGS_PATTERN, (whole, indirectionMark, id, options) => {
        if (indirectionMark != null) {
            throw Error(`Invalid Placeholder: ${whole}`)
        }
        if (id === "@") {
            return shellQuote.quote(args)
        }
        if (id === "*") {
            return shellQuote.quote([args.join(" ")])
        }

        const position = parseInt(id, 10)
        if (position >= 1 && position <= args.length) {
            return shellQuote.quote([args[position - 1]])
        }

        // Address default values
        if (options != null) {
            const prefix = options.slice(0, 2)

            if (prefix === ":=") {
                defaults[id] = shellQuote.quote([options.slice(2)])
github appium / node-teen_process / lib / exec.js View on Github external
async function exec (cmd, args = [], opts = {}) {
  // get a quoted representation of the command for error strings
  const rep = quote([cmd, ...args]);

  // extend default options; we're basically re-implementing exec's options
  // for use here with spawn under the hood
  opts = Object.assign({
    timeout: null,
    encoding: 'utf8',
    killSignal: 'SIGTERM',
    cwd: undefined,
    env: process.env,
    ignoreOutput: false,
    stdio: 'inherit',
    isBuffer: false,
    shell: undefined,
    logger: undefined,
    maxStdoutBufferSize: MAX_BUFFER_SIZE,
    maxStderrBufferSize: MAX_BUFFER_SIZE,
github release-it / release-it / lib / plugin / git / Git.js View on Github external
tag({ name = this.options.tagName, annotation = this.options.tagAnnotation, args = this.options.tagArgs } = {}) {
    const quotedMessage = quote([format(annotation, this.getContext())]);
    return this.exec(`git tag --annotate --message=${quotedMessage} ${args || ''} ${name}`)
      .then(() => this.setContext({ isTagged: true }))
      .catch(err => {
        const { latestTagName, tagName } = this.getContext();
        if (/tag '.+' already exists/.test(err) && latestTagName === tagName) {
          this.log.warn(`Tag "${tagName}" already exists`);
        } else {
          throw err;
        }
      });
  }
github TJkrusinski / NodePDF / child.js View on Github external
exports.exec = function(url, filename, options, cb){
  var key;
  var stdin = ['phantomjs'];

  stdin.push(options.args);
  stdin.push(shq([
    __dirname+'/render.js',
    url,
    filename,
    new Buffer(JSON.stringify(options)).toString('base64')
  ]));

  return child.exec(stdin.join(' '), function(err, stdo, stde){
    cb ? cb(err) : null;
  });
};
github oleics / node-yawatch / bin / cli.js View on Github external
function execProcess(cmd, cb) {
  exec(shellQuote(cmd), function(err, stdout, stderr) {
    process.stdout.write(stdout);
    process.stderr.write(stderr);
    if(err) return cb(err);
    cb();
  });
}
github mattdesl / ghrepo / index.js View on Github external
module.exports.add = function(opt, cb) {
  cb = cb || noop
  var message = opt.message || 'first commit'
  message = quote([message])

  var cmd = [
    'git init',
    'git add .',
    'git commit -m ' + message,
    'git remote add origin ' + opt.url,
    'git push -u origin master'
  ].join(' && ')
  var proc = spawn(cmd, [], {
    stdio: 'inherit'
  })
  proc.on('exit', function(code) {
    if (code === 0)
      cb()
    else
      cb(new Error("error code " + code))
github appium / appium-adb / lib / tools / adb-commands.js View on Github external
cmd.push('--time-limit', timeLimit);
  }
  if (util.hasValue(bitRate)) {
    cmd.push('--bit-rate', bitRate);
  }
  if (bugReport) {
    cmd.push('--bugreport');
  }
  cmd.push(destination);

  const fullCmd = [
    ...this.executable.defaultArgs,
    'shell',
    ...cmd
  ];
  log.debug(`Building screenrecord process with the command line: adb ${quote(fullCmd)}`);
  return new SubProcess(this.executable.path, fullCmd);
};
github danielbeardsley / cimpler / plugins / git-build.js View on Github external
quote = function (input) {
       return shellQuote([input]);
    }
exports.init = function(config, cimpler) {
github UnitedIncome / serverless-python-requirements / lib / pip.js View on Github external
}

  let spawnArgs = { shell: true };
  if (process.env.SLS_DEBUG) {
    spawnArgs.stdio = 'inherit';
  }
  let mainCmds = [];
  if (dockerCmd.length) {
    dockerCmd.push(...mergeCommands(pipCmds));
    mainCmds = [dockerCmd];
  } else {
    mainCmds = pipCmds;
  }
  mainCmds.push(...postCmds);

  serverless.cli.log(`Running ${quote(dockerCmd)}...`);

  filterCommands(mainCmds).forEach(([cmd, ...args]) => {
    const res = spawnSync(cmd, args);
    if (res.error) {
      if (res.error.code === 'ENOENT') {
        const advice =
          cmd.indexOf('python') > -1
            ? 'Try the pythonBin option'
            : 'Please install it';
        throw new Error(`${cmd} not found! ${advice}`);
      }
      throw res.error;
    }
    if (res.status !== 0) {
      throw new Error(`STDOUT: ${res.stdout}\n\nSTDERR: ${res.stderr}`);
    }
github makeflow / remote-workspace / src / server / @core / generated-file / files / @utils.ts View on Github external
export async function writeTextFileToVolume(
  dockerComposeProjectName: string,
  volume: string,
  path: string,
  text: string,
  mode?: string,
): Promise {
  if (Path.isAbsolute(path)) {
    throw new Error('The provided `path` must be relative');
  }

  let quotedPath = ShellQuote.quote([Path.posix.join('/volume', path)]);

  let commands = [`echo ${ShellQuote.quote(['-n', text])} > ${quotedPath}`];

  if (mode) {
    commands.push(`chmod ${ShellQuote.quote([mode])} ${quotedPath}`);
  }

  let subprocess = ChildProcess.spawn('docker', [
    'run',
    '--rm',
    '--volume',
    `${dockerComposeProjectName}_${volume}:/volume`,
    'alpine',
    'sh',
    '-c',
    commands.join(' && '),
  ]);

shell-quote

quote and parse shell commands

MIT
Latest version published 1 year ago

Package Health Score

77 / 100
Full package analysis

Popular shell-quote functions