How to use the @actions/exec/lib/exec.exec function in @actions/exec

To help you get started, we’ve selected a few @actions/exec 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 actions / setup-node / node_modules / @actions / tool-cache / lib / tool-cache.js View on Github external
dest = dest || (yield _createExtractFolder(dest));
        const originalCwd = process.cwd();
        process.chdir(dest);
        if (_7zPath) {
            try {
                const args = [
                    'x',
                    '-bb1',
                    '-bd',
                    '-sccUTF-8',
                    file
                ];
                const options = {
                    silent: true
                };
                yield exec_1.exec(`"${_7zPath}"`, args, options);
            }
            finally {
                process.chdir(originalCwd);
            }
        }
        else {
            const escapedScript = path
                .join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
                .replace(/'/g, "''")
                .replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
            const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
            const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
            const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
            const args = [
                '-NoLogo',
                '-Sta',
github actions / typescript-action / node_modules / @actions / tool-cache / lib / tool-cache.js View on Github external
dest = dest || (yield _createExtractFolder(dest));
        const originalCwd = process.cwd();
        process.chdir(dest);
        if (_7zPath) {
            try {
                const args = [
                    'x',
                    '-bb1',
                    '-bd',
                    '-sccUTF-8',
                    file
                ];
                const options = {
                    silent: true
                };
                yield exec_1.exec(`"${_7zPath}"`, args, options);
            }
            finally {
                process.chdir(originalCwd);
            }
        }
        else {
            const escapedScript = path
                .join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
                .replace(/'/g, "''")
                .replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
            const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
            const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
            const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
            const args = [
                '-NoLogo',
                '-Sta',
github shivammathur / setup-php / src / install.ts View on Github external
// check the os version and run the respective script
    let script_path = '';
    switch (os_version) {
      case 'darwin':
        script_path = await build(os_version + '.sh', version, os_version);
        await exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
        break;
      case 'linux': {
        const pecl: string = await utils.getInput('pecl', false);
        script_path = await build(os_version + '.sh', version, os_version);
        await exec('sh ' + script_path + ' ' + version + ' ' + pecl);
        break;
      }
      case 'win32':
        script_path = await build('win32.ps1', version, os_version);
        await exec(
          'pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname
        );
        break;
    }
    await matchers.addMatchers();
  } catch (error) {
    core.setFailed(error.message);
  }
}
github shivammathur / setup-php / src / install.ts View on Github external
export async function run(): Promise {
  try {
    const os_version: string = process.platform;
    let version: string = await utils.getInput('php-version', true);
    version = version.length > 1 ? version : version + '.0';
    // check the os version and run the respective script
    let script_path = '';
    switch (os_version) {
      case 'darwin':
        script_path = await build(os_version + '.sh', version, os_version);
        await exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
        break;
      case 'linux': {
        const pecl: string = await utils.getInput('pecl', false);
        script_path = await build(os_version + '.sh', version, os_version);
        await exec('sh ' + script_path + ' ' + version + ' ' + pecl);
        break;
      }
      case 'win32':
        script_path = await build('win32.ps1', version, os_version);
        await exec(
          'pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname
        );
        break;
    }
    await matchers.addMatchers();
  } catch (error) {
github actions / toolkit / packages / tool-cache / src / tool-cache.ts View on Github external
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '')
  const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`

  // run powershell
  const powershellPath = await io.which('powershell')
  const args = [
    '-NoLogo',
    '-Sta',
    '-NoProfile',
    '-NonInteractive',
    '-ExecutionPolicy',
    'Unrestricted',
    '-Command',
    command
  ]
  await exec(`"${powershellPath}"`, args)
}
github actions / setup-ruby / node_modules / @actions / tool-cache / lib / tool-cache.js View on Github external
dest = dest || (yield _createExtractFolder(dest));
        const originalCwd = process.cwd();
        process.chdir(dest);
        if (_7zPath) {
            try {
                const args = [
                    'x',
                    '-bb1',
                    '-bd',
                    '-sccUTF-8',
                    file
                ];
                const options = {
                    silent: true
                };
                yield exec_1.exec(`"${_7zPath}"`, args, options);
            }
            finally {
                process.chdir(originalCwd);
            }
        }
        else {
            const escapedScript = path
                .join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
                .replace(/'/g, "''")
                .replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
            const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
            const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
            const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
            const args = [
                '-NoLogo',
                '-Sta',
github actions / toolkit / packages / tool-cache / src / tool-cache.ts View on Github external
async function extractZipNix(file: string, dest: string): Promise {
  const unzipPath = await io.which('unzip')
  await exec(`"${unzipPath}"`, [file], {cwd: dest})
}
github subosito / flutter-action / node_modules / @actions / tool-cache / lib / tool-cache.js View on Github external
const args = [
                '-NoLogo',
                '-Sta',
                '-NoProfile',
                '-NonInteractive',
                '-ExecutionPolicy',
                'Unrestricted',
                '-Command',
                command
            ];
            const options = {
                silent: true
            };
            try {
                const powershellPath = yield io.which('powershell', true);
                yield exec_1.exec(`"${powershellPath}"`, args, options);
            }
            finally {
                process.chdir(originalCwd);
            }
        }
        return dest;
    });
}
github actions / toolkit / packages / tool-cache / src / tool-cache.ts View on Github external
const args: string[] = [
      '-NoLogo',
      '-Sta',
      '-NoProfile',
      '-NonInteractive',
      '-ExecutionPolicy',
      'Unrestricted',
      '-Command',
      command
    ]
    const options: ExecOptions = {
      silent: true
    }
    try {
      const powershellPath: string = await io.which('powershell', true)
      await exec(`"${powershellPath}"`, args, options)
    } finally {
      process.chdir(originalCwd)
    }
  }

  return dest
}