exec(name, arguments)

Executes any CLI command in the current working directory. This example demonstrates the logic for extracting the name and arguments of a sample CLI command: npm i -g codemod translates to exec('npm', ['i', '-g', 'codemod']). Here are some examples in real scenarios.

import { exec, git } from '@codemod.com/workflow'
await git.clone('git@github.com:codemod-com/codemod.git', async ({ files, branch, commit, push, exec }) => {
    await branch('remove-jquery-extend')
    await files()
        .jsFam()
        .astGrep('$.extend({}, $A, $B)')
        .replace('{ ...$A, ...$B }')
    // verify change didn't break tests
    await exec('pnpm', ['install'])
        .exec('pnpm', ['lint'])
        .exec('pnpm', ['test'])
        .exec('pnpm', ['e2e'])
    await commit('replaced jquery.extend with object spread')
    await push()
})

Parameters

name
string
required

Command name.

arguments
string[]

Arguments passed to command.

Returns