How to use the exec function from shelljs
Find comprehensive JavaScript shelljs.exec code examples handpicked from public code repositorys.
24 25 26 27 28 29 30 31 32 33
signale.info(`Did not find an existing code-intel-extensions bundles matching revision ${revision}.`) signale.pending('Fetching code intel extensions bundles...') const result = shelljs.exec(`curl -OLs https://github.com/sourcegraph/${bundlesRepoName}/archive/${revision}.zip`) if (result.code !== 0) { console.error('Curl command failed with exit code:', result.code) console.error('Error message:', result.stderr)
936
0
161
+ 11 other calls in file
GitHub: crimx/ext-saladict
131 132 133 134 135 136 137 138 139 140
shell.exit(1) } } function exec(command, errorMsg) { const execResult = shell.exec(command) if (execResult.code !== 0) { if (errorMsg) { shell.echo(errorMsg)
669
0
88
44 45 46 47 48 49 50 51 52 53
shell.echo( `ℹ️ Pull Requests are welcome to add support for "msgcat" on Windows!` ); shell.exit(0); } else { msgcat = shell.exec('which msgcat 2>/dev/null', { silent: true }).stdout; if (!msgcat) { msgcat = shell.exec('find /usr -name "msgcat" -print -quit 2>/dev/null', { silent: true, }).stdout;
621
0
161
+ 5 other calls in file
GitHub: embarklabs/embark
15 16 17 18 19 20 21 22 23 24
} compileVyperContract(filename, compileABI, callback) { const self = this; const params = compileABI ? '-f=json ' : ''; shelljs.exec(`vyper ${params}${filename}`, {silent: true}, (code, stdout, stderr) => { if (stderr) { return callback(stderr); } if (code !== 0) {
533
0
132
115 116 117 118 119 120 121 122 123 124
sh.cd(extensionDir); extensionList.forEach(extension => { if (sh.test('-d', extension.path)) { sh.cd(extension.path); sh.exec('git checkout ' + extensionBranch); sh.exec('git pull'); } else { sh.exec('git clone -b ' + extensionBranch + ' ' + extension.url); sh.cd(extension.path);
369
0
92
+ 11 other calls in file
GitHub: txd-team/docsite
33 34 35 36 37 38 39 40 41 42
fs.copySync(path.join(__dirname, '../website'), dir); console.log(chalk.green('Project folder was created successfully.')); shell.cd(dir); try { shell.exec('npm i'); } catch (err) { console.log(chalk.red('Dependencies install failed, please reinstall again!')); process.exit(1); }
236
0
46
53 54 55 56 57 58 59 60 61
console.log('📍Failed to destroy aws key-pair remotely') process.exit(1) } console.log(`📍 Removing key-pair for ${keyName} locally ...`) shell.exec(`rm ./${keyName}.pem`) if (shell.error() !== null) { console.log(`📍Failed to delete ${keyName}.pem locally`) }
37
39
29
+ 44 other calls in file
GitHub: maticnetwork/matic-cli
8 9 10 11 12 13 14 15 16 17
const nextDevnetId = !fs.existsSync('./deployments') ? 1 : findMaxDevnetId() + 1 shell.exec(`mkdir -p ./deployments/devnet-${nextDevnetId}`) shell.exec(`cp ./.env ./deployments/devnet-${nextDevnetId}/.env`) shell.exec( `cp ./secret.tfvars ./deployments/devnet-${nextDevnetId}/secret.tfvars` ) shell.exec(`cp ./main.tf ./deployments/devnet-${nextDevnetId}/main.tf`)
37
39
0
+ 6 other calls in file
200 201 202 203 204 205 206 207 208 209
return new Promise(async (resolve, reject) => { try { shell.cd(STATIC_URL) const targz = `tar zcf bklesscode-proj-${projectId}.tar.gz -C ./${sourceDir} .` shell.exec(targz) shell.cd(projectPath) const uploadKey = `project/${projectId}/${version}/${releaseId}/` const url = await fileService.uploadFile(`${targetPath}.tar.gz`, uploadKey)
32
31
9
59 60 61 62 63 64 65 66 67 68
const feesFileId = 111; const queryFees = new HederaSDK.FileContentsQuery() .setFileId(`0.0.${feesFileId}`); const fees = (await queryFees.execute(client)).toString('hex'); await shell.exec( `docker exec mirror-node-db psql mirror_node -U mirror_node -c "INSERT INTO public.file_data(file_data, consensus_timestamp, entity_id, transaction_type) VALUES (decode('${fees}', 'hex'), ${timestamp + '000000'}, ${feesFileId}, 17);" >> ${NodeController.getNullOutput()}` ); const exchangeRatesFileId = 112;
25
26
0
+ 3 other calls in file
GitHub: zhangfisher/voerka-i18n
331 332 333 334 335 336 337 338 339 340 341
/** * 检测当前工程是否是git工程 */ function isGitRepo(){ return shelljs.exec("git status", {silent: true}).code === 0; } /** * 简单进行对象合并
3
24
3
+ 167 other calls in file
21 22 23 24 25 26 27 28 29 30 31
gulp.task("aspmvc-build", aspmvcBuild); gulp.task('deploy', function(done) { // remove clone folder shelljs.rm('-rf', './ej2aspmvc'); var commitMessage = shelljs.exec('git log -1 --pretty=%B').stdout.trim(); console.log('COMMIT MESSAGE: ' + commitMessage); // create clone directory fs.mkdirSync('./ej2aspmvc'); // navigate to clone location
27
9
13
+ 199 other calls in file
GitHub: grucloud/grucloud
722 723 724 725 726 727 728 729 730 731
pipe([ tap(() => { logger.debug(`shellRun: ${fullCommand}`); }), () => shell.exec(fullCommand, { silent: true, }), switchCase([ eq(get("code"), 0),
12
78
6
+ 17 other calls in file
331 332 333 334 335 336 337 338 339 340
return filenames } else { const command = `git diff --name-only --diff-filter=AMR origin/${branch}` debugGit('command: %s', command) const result = shell.exec(command, { silent: true }) if (result.code !== 0) { debugGit('git diff failed with code %d', result.code) return [] }
6
26
2
+ 44 other calls in file
GitHub: liondocs/cli
6 7 8 9 10 11 12 13 14 15 16 17 18
} function shellExecute (command) { const { exec } = require('shelljs') return exec(command, { silent: true }).stdout } function gitLogCommand (path) { return `git log --pretty=format:'%H' -n 1 ${path}`
3
4
1
+ 22 other calls in file
GitHub: liondocs/cli
8 9 10 11 12 13 14 15 16 17 18 19
}) it('returns the last file SHA', () => { const pathToFile = `${process.cwd()}/test/fixtures/test.txt` const gitLogCommand = `git log --pretty=format:'%H' -n 1 ${pathToFile}` const expectedSha = exec(gitLogCommand, { silent: true }).stdout expect(sha(pathToFile)).toEqual(expectedSha) }) })
3
4
1
+ 22 other calls in file
9 10 11 12 13 14 15 16 17 18
{ console.error('Script must be run with the commit SHA for the latest merged PR to pixijs/pixijs dev!'); process.exit(1); } shell.exec('npm view pixi.js --json > scripts/pixiVersions.json'); const codeSandboxBaseUrl = `https://pkg.csb.dev/pixijs/pixijs/commit/${devCommitSha.substring(0, 8)}`; // eslint-disable-next-line global-require
1
6
4
+ 5 other calls in file
99 100 101 102 103 104 105 106 107
// start the Metro server in a separate window launchPackagerInSeparateWindow(); // launch the app on iOS simulator pushd('packages/rn-tester'); exec('npx react-native run-ios --scheme RNTester --simulator "iPhone 14"'); popd(); } else { // we do the android path here
2
0
0
+ 33 other calls in file
GitHub: TomMalbran/Runner
9 10 11 12 13 14 15 16 17 18 19
* Executes a Command * @param {String} command * @returns {Void} */ function exec(command) { Shell.exec(command); } /** * Executes a Silent Command
0
3
0
+ 3 other calls in file
130 131 132 133 134 135 136 137 138 139 140
exit(1); } } function checkIfTagExists(version) { const {code, stdout} = exec('git tag -l', {silent: true}); if (code !== 0) { throw new Error('Failed to retrieve the list of tags'); } const tags = new Set(stdout.split('\n'));
2
0
0
+ 9 other calls in file
shelljs.exec is the most popular function in shelljs (4615 examples)