Skip to content

Commit

Permalink
fix: Add quiet option to sh() command
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomatsubara committed Jun 13, 2024
1 parent 9ac8b15 commit 1b10dc3
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 46 deletions.
8 changes: 4 additions & 4 deletions dist/build-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127551,11 +127551,11 @@ function sh(cmd, options) {
options.cwd = options.cwd != null ? options.cwd : ".";
options.check = options.check != null ? options.check : true;
options.input = options.input != null ? options.input : "";
options.quiet = options.quiet != null ? options.quiet : false;
_actions_core__WEBPACK_IMPORTED_MODULE_1__.startGroup(`\u001b[1m\u001b[35m${cmd}\u001b[0m`);
const returns = (0,child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync)(cmd, {
// NOTE: Environment variables defined in `options.env` take precedence over
// the parent process's environment, thus the destructuring is order is
// important
// the parent process's environment, thus the destructuring order is important
env: {
...process.env,
...options.env,
Expand All @@ -127567,11 +127567,11 @@ function sh(cmd, options) {
input: options.input,
maxBuffer: MAX_BUFFER,
});
if (returns.stdout != "") {
if (returns.stdout != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstdout:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stdout);
}
if (returns.stderr != "") {
if (returns.stderr != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstderr:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stderr);
}
Expand Down
8 changes: 4 additions & 4 deletions dist/build-crates-standalone-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127536,11 +127536,11 @@ function sh(cmd, options) {
options.cwd = options.cwd != null ? options.cwd : ".";
options.check = options.check != null ? options.check : true;
options.input = options.input != null ? options.input : "";
options.quiet = options.quiet != null ? options.quiet : false;
_actions_core__WEBPACK_IMPORTED_MODULE_1__.startGroup(`\u001b[1m\u001b[35m${cmd}\u001b[0m`);
const returns = (0,child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync)(cmd, {
// NOTE: Environment variables defined in `options.env` take precedence over
// the parent process's environment, thus the destructuring is order is
// important
// the parent process's environment, thus the destructuring order is important
env: {
...process.env,
...options.env,
Expand All @@ -127552,11 +127552,11 @@ function sh(cmd, options) {
input: options.input,
maxBuffer: MAX_BUFFER,
});
if (returns.stdout != "") {
if (returns.stdout != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstdout:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stdout);
}
if (returns.stderr != "") {
if (returns.stderr != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstderr:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stderr);
}
Expand Down
8 changes: 4 additions & 4 deletions dist/bump-crates-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -81257,11 +81257,11 @@ function sh(cmd, options) {
options.cwd = options.cwd != null ? options.cwd : ".";
options.check = options.check != null ? options.check : true;
options.input = options.input != null ? options.input : "";
options.quiet = options.quiet != null ? options.quiet : false;
_actions_core__WEBPACK_IMPORTED_MODULE_1__.startGroup(`\u001b[1m\u001b[35m${cmd}\u001b[0m`);
const returns = (0,child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync)(cmd, {
// NOTE: Environment variables defined in `options.env` take precedence over
// the parent process's environment, thus the destructuring is order is
// important
// the parent process's environment, thus the destructuring order is important
env: {
...process.env,
...options.env,
Expand All @@ -81273,11 +81273,11 @@ function sh(cmd, options) {
input: options.input,
maxBuffer: MAX_BUFFER,
});
if (returns.stdout != "") {
if (returns.stdout != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstdout:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stdout);
}
if (returns.stderr != "") {
if (returns.stderr != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstderr:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stderr);
}
Expand Down
8 changes: 4 additions & 4 deletions dist/create-release-branch-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24749,11 +24749,11 @@ function sh(cmd, options) {
options.cwd = options.cwd != null ? options.cwd : ".";
options.check = options.check != null ? options.check : true;
options.input = options.input != null ? options.input : "";
options.quiet = options.quiet != null ? options.quiet : false;
lib_core.startGroup(`\u001b[1m\u001b[35m${cmd}\u001b[0m`);
const returns = (0,external_child_process_namespaceObject.spawnSync)(cmd, {
// NOTE: Environment variables defined in `options.env` take precedence over
// the parent process's environment, thus the destructuring is order is
// important
// the parent process's environment, thus the destructuring order is important
env: {
...process.env,
...options.env,
Expand All @@ -24765,11 +24765,11 @@ function sh(cmd, options) {
input: options.input,
maxBuffer: MAX_BUFFER,
});
if (returns.stdout != "") {
if (returns.stdout != "" && !options.quiet) {
lib_core.info(`\u001b[1mstdout:\u001b[0m`);
lib_core.info(returns.stdout);
}
if (returns.stderr != "") {
if (returns.stderr != "" && !options.quiet) {
lib_core.info(`\u001b[1mstderr:\u001b[0m`);
lib_core.info(returns.stderr);
}
Expand Down
8 changes: 4 additions & 4 deletions dist/publish-crates-cargo-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -81145,11 +81145,11 @@ function sh(cmd, options) {
options.cwd = options.cwd != null ? options.cwd : ".";
options.check = options.check != null ? options.check : true;
options.input = options.input != null ? options.input : "";
options.quiet = options.quiet != null ? options.quiet : false;
_actions_core__WEBPACK_IMPORTED_MODULE_1__.startGroup(`\u001b[1m\u001b[35m${cmd}\u001b[0m`);
const returns = (0,child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync)(cmd, {
// NOTE: Environment variables defined in `options.env` take precedence over
// the parent process's environment, thus the destructuring is order is
// important
// the parent process's environment, thus the destructuring order is important
env: {
...process.env,
...options.env,
Expand All @@ -81161,11 +81161,11 @@ function sh(cmd, options) {
input: options.input,
maxBuffer: MAX_BUFFER,
});
if (returns.stdout != "") {
if (returns.stdout != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstdout:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stdout);
}
if (returns.stderr != "") {
if (returns.stderr != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstderr:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stderr);
}
Expand Down
14 changes: 7 additions & 7 deletions dist/publish-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127531,11 +127531,11 @@ function sh(cmd, options) {
options.cwd = options.cwd != null ? options.cwd : ".";
options.check = options.check != null ? options.check : true;
options.input = options.input != null ? options.input : "";
options.quiet = options.quiet != null ? options.quiet : false;
_actions_core__WEBPACK_IMPORTED_MODULE_1__.startGroup(`\u001b[1m\u001b[35m${cmd}\u001b[0m`);
const returns = (0,child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync)(cmd, {
// NOTE: Environment variables defined in `options.env` take precedence over
// the parent process's environment, thus the destructuring is order is
// important
// the parent process's environment, thus the destructuring order is important
env: {
...process.env,
...options.env,
Expand All @@ -127547,11 +127547,11 @@ function sh(cmd, options) {
input: options.input,
maxBuffer: MAX_BUFFER,
});
if (returns.stdout != "") {
if (returns.stdout != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstdout:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stdout);
}
if (returns.stderr != "") {
if (returns.stderr != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstderr:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stderr);
}
Expand Down Expand Up @@ -127736,9 +127736,9 @@ async function main(input) {
(0,_command__WEBPACK_IMPORTED_MODULE_5__.sh)("sudo apt-get install -y dpkg-dev");
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(packagesPath, (0,_command__WEBPACK_IMPORTED_MODULE_5__.sh)(`dpkg-scanpackages --multiversion ${input.version}`));
// NOTE: An unzipped package index is necessary for apt-get to recognize the
// local repository created below. By redirecting the output we also avoid breaking the Github webUI displaying too much data.
(0,_command__WEBPACK_IMPORTED_MODULE_5__.sh)(`cat .Packages-* > ${allPackagesPath}`);
const packages = await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(allPackagesPath, "utf8");
// local repository created below
const packages = (0,_command__WEBPACK_IMPORTED_MODULE_5__.sh)(`cat .Packages-*`, { quiet: true });
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(allPackagesPath, packages);
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(allPackagesGzippedPath, await gzip(packages));
(0,_command__WEBPACK_IMPORTED_MODULE_5__.sh)("ls -R");
_actions_core__WEBPACK_IMPORTED_MODULE_2__.info(`Adding a local Debian repository at ${process.cwd()}`);
Expand Down
8 changes: 4 additions & 4 deletions dist/publish-crates-eclipse-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127633,11 +127633,11 @@ function sh(cmd, options) {
options.cwd = options.cwd != null ? options.cwd : ".";
options.check = options.check != null ? options.check : true;
options.input = options.input != null ? options.input : "";
options.quiet = options.quiet != null ? options.quiet : false;
_actions_core__WEBPACK_IMPORTED_MODULE_1__.startGroup(`\u001b[1m\u001b[35m${cmd}\u001b[0m`);
const returns = (0,child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync)(cmd, {
// NOTE: Environment variables defined in `options.env` take precedence over
// the parent process's environment, thus the destructuring is order is
// important
// the parent process's environment, thus the destructuring order is important
env: {
...process.env,
...options.env,
Expand All @@ -127649,11 +127649,11 @@ function sh(cmd, options) {
input: options.input,
maxBuffer: MAX_BUFFER,
});
if (returns.stdout != "") {
if (returns.stdout != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstdout:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stdout);
}
if (returns.stderr != "") {
if (returns.stderr != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstderr:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stderr);
}
Expand Down
8 changes: 4 additions & 4 deletions dist/publish-crates-github-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127612,11 +127612,11 @@ function sh(cmd, options) {
options.cwd = options.cwd != null ? options.cwd : ".";
options.check = options.check != null ? options.check : true;
options.input = options.input != null ? options.input : "";
options.quiet = options.quiet != null ? options.quiet : false;
_actions_core__WEBPACK_IMPORTED_MODULE_1__.startGroup(`\u001b[1m\u001b[35m${cmd}\u001b[0m`);
const returns = (0,child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync)(cmd, {
// NOTE: Environment variables defined in `options.env` take precedence over
// the parent process's environment, thus the destructuring is order is
// important
// the parent process's environment, thus the destructuring order is important
env: {
...process.env,
...options.env,
Expand All @@ -127628,11 +127628,11 @@ function sh(cmd, options) {
input: options.input,
maxBuffer: MAX_BUFFER,
});
if (returns.stdout != "") {
if (returns.stdout != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstdout:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stdout);
}
if (returns.stderr != "") {
if (returns.stderr != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstderr:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stderr);
}
Expand Down
8 changes: 4 additions & 4 deletions dist/publish-crates-homebrew-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127537,11 +127537,11 @@ function sh(cmd, options) {
options.cwd = options.cwd != null ? options.cwd : ".";
options.check = options.check != null ? options.check : true;
options.input = options.input != null ? options.input : "";
options.quiet = options.quiet != null ? options.quiet : false;
_actions_core__WEBPACK_IMPORTED_MODULE_1__.startGroup(`\u001b[1m\u001b[35m${cmd}\u001b[0m`);
const returns = (0,child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync)(cmd, {
// NOTE: Environment variables defined in `options.env` take precedence over
// the parent process's environment, thus the destructuring is order is
// important
// the parent process's environment, thus the destructuring order is important
env: {
...process.env,
...options.env,
Expand All @@ -127553,11 +127553,11 @@ function sh(cmd, options) {
input: options.input,
maxBuffer: MAX_BUFFER,
});
if (returns.stdout != "") {
if (returns.stdout != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstdout:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stdout);
}
if (returns.stderr != "") {
if (returns.stderr != "" && !options.quiet) {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`\u001b[1mstderr:\u001b[0m`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(returns.stderr);
}
Expand Down
9 changes: 5 additions & 4 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type CommandOptions = {
cwd?: string;
check?: boolean;
input?: string;
quiet?: boolean;
};

export function sh(cmd: string, options?: CommandOptions): string {
Expand All @@ -16,13 +17,13 @@ export function sh(cmd: string, options?: CommandOptions): string {
options.cwd = options.cwd != null ? options.cwd : ".";
options.check = options.check != null ? options.check : true;
options.input = options.input != null ? options.input : "";
options.quiet = options.quiet != null ? options.quiet : false;

core.startGroup(`\u001b[1m\u001b[35m${cmd}\u001b[0m`);

const returns = spawnSync(cmd, {
// NOTE: Environment variables defined in `options.env` take precedence over
// the parent process's environment, thus the destructuring is order is
// important
// the parent process's environment, thus the destructuring order is important
env: {
...process.env,
...options.env,
Expand All @@ -35,12 +36,12 @@ export function sh(cmd: string, options?: CommandOptions): string {
maxBuffer: MAX_BUFFER,
});

if (returns.stdout != "") {
if (returns.stdout != "" && !options.quiet) {
core.info(`\u001b[1mstdout:\u001b[0m`);
core.info(returns.stdout);
}

if (returns.stderr != "") {
if (returns.stderr != "" && !options.quiet) {
core.info(`\u001b[1mstderr:\u001b[0m`);
core.info(returns.stderr);
}
Expand Down
6 changes: 3 additions & 3 deletions src/publish-crates-debian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ export async function main(input: Input) {

await fs.writeFile(packagesPath, sh(`dpkg-scanpackages --multiversion ${input.version}`));
// NOTE: An unzipped package index is necessary for apt-get to recognize the
// local repository created below. By redirecting the output we also avoid breaking the Github webUI displaying too much data.
sh(`cat .Packages-* > ${allPackagesPath}`);
const packages = await fs.readFile(allPackagesPath, "utf8");
// local repository created below
const packages = sh(`cat .Packages-*`, {quiet: true});
await fs.writeFile(allPackagesPath, packages);
await fs.writeFile(allPackagesGzippedPath, await gzip(packages));

sh("ls -R");
Expand Down

0 comments on commit 1b10dc3

Please sign in to comment.