How to use the echo function from shelljs

Find comprehensive JavaScript shelljs.echo code examples handpicked from public code repositorys.

4
5
6
7
8
9
10
11
12
13
const shell = require('shelljs')
const path = require('path')
const fs = require('fs-extra')

if (!shell.which('git')) {
  shell.echo('Sorry, this script requires git')
  shell.exit(1)
}

const cacheDir = 'pdf'
fork icon669
star icon0
watch icon88

+ 13 other calls in file

38
39
40
41
42
43
44
45
46
47
  });

// Identify where msgcat is on the system
let msgcat = '';
if (isWin) {
  shell.echo(`ℹ️ Skipping translations compilation on Windows.`);
  shell.echo(
    `ℹ️ Pull Requests are welcome to add support for "msgcat" on Windows!`
  );
  shell.exit(0);
fork icon621
star icon0
watch icon161

+ 7 other calls in file

215
216
217
218
219
220
221
222
223
224

```
var shell = require('shelljs');

if (!shell.which('git')) {
  shell.echo('Sorry, this script requires git');
  shell.exit(1);
}

// Copy files to release dir
fork icon143
star icon736
watch icon51

+ 3 other calls in file

-1
fork icon369
star icon0
watch icon92

+ 3 other calls in file

13
14
15
16
17
18
19
20
21
22
23
  createHermesPrebuiltArtifactsTarball,
} = require('../packages/react-native/scripts/hermes/hermes-utils');


function generateAndroidArtifacts(releaseVersion) {
  // -------- Generating Android Artifacts
  echo('Generating Android artifacts inside /tmp/maven-local');
  if (exec('./gradlew publishAllToMavenTempLocal').code) {
    echo('Could not generate artifacts');
    exit(1);
  }
fork icon2
star icon0
watch icon0

+ 19 other calls in file

58
59
60
61
62
63
64
65
66
67
68
      buildTs();
      npmPublish();
      break;


    default:
      shell.echo("No arg provided, doing nothing...");
      break;
  }
}

fork icon0
star icon1
watch icon0

+ 8 other calls in file

139
140
141
142
143
144
145
146
147
148
149
    /^VERSION_NAME=.*/,
    `VERSION_NAME=${version}`,
    'packages/react-native/ReactAndroid/gradle.properties',
  ).code
) {
  echo("Couldn't update version for Gradle");
  exit(1);
}


// Change react-native version in the template's package.json
fork icon2
star icon0
watch icon4

+ 24 other calls in file

68
69
70
71
72
73
74
75
76
77
78


function sh(executable, ...args) {
  let command = `${executable} ${args.join('')}`;
  let result = shell.exec(command, { silent: true });
  if (result.code !== 0) {
    shell.echo(`Error: Command "${command}" failed\n${result.stderr}`);
    shell.exit(result.code);
  }
  return result.stdout.replace(/\s+$/, '');
}
fork icon0
star icon3
watch icon2

180
181
182
183
184
185
186
187
188
189
//       })
//       .help('h')
//       .alias('h', 'help')
//       .argv


//     echo(argv.n)
//   })
//   .argv

fork icon0
star icon1
watch icon1

+ 535 other calls in file

662
663
664
665
666
667
668
669
670
671
        removed: {}
    };
}

// 1. Update rule meta data by checking rule docs - important to catch removed rules
echo("> Updating rule version meta data (Step 1)");
const ruleDocsFiles = find(DOCS_RULES_DIR);

ruleDocsFiles.forEach((filename, i) => {
    if (test("-f", filename) && path.extname(filename) === ".md") {
fork icon0
star icon0
watch icon1

+ 1199 other calls in file

55
56
57
58
59
60
61
  shell.exec('git commit -am "init the new project and install Next.js"');
  shell.exec(`git branch -D ${branchName}`);
  shell.exec("git branch -m master");
  shell.exec("git branch -D main");
  shell.exec("git remote remove origin");
  shell.echo("New project has been created!");
});
fork icon0
star icon0
watch icon1

+ 35 other calls in file

115
116
117
118
119
120
121
122
123
124
125
126
  shell.sed('-i', /serverless_functions_domain[_]*[a-z]*/g, `serverless_functions_domain_${packageSuffixUndercore}`, `${fullPluginName}/public/appConfig.js`);
}




if(shell.test('-e', './plugin-flex-ts-template-v1')){
  shell.echo(`Removing v1 plugin`);
  shell.echo("");
  shell.rm('-rf', './plugin-flex-ts-template-v1');
}

fork icon0
star icon0
watch icon1

+ 11 other calls in file

767
768
769
770
771
772
773
774
775
776
777
778
    // 12. Delete temporary directory
    echo("> Removing the temporary directory (Step 12)");
    rm("-rf", TEMP_DIR);


    // 13. Create Example Formatter Output Page
    echo("> Creating the formatter examples (Step 14)");
    generateFormatterExamples(getFormatterResults(), prereleaseVersion);


    echo("Done generating eslint.org");
};
fork icon0
star icon0
watch icon0

+ 545 other calls in file

116
117
118
119
120
121
122
123
124
125
  // if this is successful, the feature directory already exists
  shell.echo("feature directory already exists, abandoning");
  shell.echo("");
  return false;
} catch {
  shell.echo("Creating feature");
  shell.mkdir(newFeatureDirectory);
  shell.cp('-R', `${templateDirectory}/feature-template/.`, `${newFeatureDirectory}/`);
  return true;
}
fork icon0
star icon0
watch icon1

+ 124 other calls in file

40
41
42
43
44
45
46
47
48
49
branch = exec('git symbolic-ref --short HEAD', {
  silent: true,
}).stdout.trim();

if (branch.indexOf('-stable') === -1) {
  echo('You must be in 0.XX-stable branch to bump a version');
  exit(1);
}

// e.g. 0.33
fork icon0
star icon0
watch icon1

+ 49 other calls in file

129
130
131
132
133
134
135
136
137
138
139
    sh.ShellString(JSON.stringify(newTsconfigJson, null, 4)).to(filesInfo.tsconfigJsonPath);
    done();
});


gulp.task('packageJson', function (done) {
    sh.echo(`> Prepare ${filesInfo.packageJsonPath}`);
    let newPackageJson = {
        ...packageJson,
        ...packagePaths,
        name: packageName,
fork icon0
star icon0
watch icon1

+ 207 other calls in file

51
52
53
54
55
56
57
58
59
60
61
62
63




sh.echo(chalk.cyanBright('Start building:'));


gulp.task('prepare', function (done) {
    sh.echo(`> Removing ${filesInfo.distFolder}`);
    sh.rm('-rf', filesInfo.distFolder);
    done();
});

fork icon0
star icon0
watch icon1

+ 207 other calls in file

122
123
124
125
126
127
128
129
130
131

const cnt = ('0000' + this.count).slice(-3)
const name = `${cnt}-${props.boardName}-${props.content}-` +
    `${props.syscalls}-${props.trace}-${props.language}`

shx.echo()
shx.echo(`Testing '${name}'...`)

const tmp = shx.tempdir()
const buildFolder = `${tmp}/sifive-templates/${name}`
fork icon0
star icon0
watch icon0

+ 49 other calls in file

83
84
85
86
87
88
89
90
91
92

shell.cd(Path);
shell.exec(`git pull`, (code, stdout, stderr) => {
  console.log(code);
  if (code === 0) {
    shell.echo('-----更新完成----')

    resolve()
  } else {
    shell.echo('-----更新失败----')
fork icon0
star icon0
watch icon1

+ 9 other calls in file

12
13
14
15
16
17
18
19
20
21
if (!shell.which("git")) {
  shell.echo("未安装git,命令无效");
  shell.exit(1);
}
if (!targetDir || !repo) {
  shell.echo("缺少参数");
  shell.exit(1);
}
if (!outputDir && fs.existsSync(targetDir)) {
  shell.echo(`当前路径下已存在该目录`);
fork icon0
star icon0
watch icon0

+ 11 other calls in file