Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fb6f95d

Browse files
committed
feat: Add new quiet option
1 parent c293c12 commit fb6f95d

File tree

6 files changed

+24
-6
lines changed

6 files changed

+24
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Run a script on multiple repositories, cloning them if needed.
2323
The script gets run with additional environment variables.
2424

2525
| Environment Variable Name | Description |
26-
|---------------------------|-----------------------------------------------------------------------------------------------------|
26+
| ------------------------- | --------------------------------------------------------------------------------------------------- |
2727
| `REPO_OWNER` | The owner of the repository |
2828
| `REPO_NAME` | The name of the repository |
2929
| `REPO` | The value of "`REPO_OWNER`/`REPO_NAME`" |

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@types/chai": "^4.3.1",
4343
"@types/chai-as-promised": "^7.1.5",
4444
"@types/mocha": "^10.0.0",
45-
"@types/node": "^18.0.0",
45+
"@types/node": "^18.13.0",
4646
"chai": "^4.3.6",
4747
"chai-as-promised": "^7.1.1",
4848
"eslint": "^8.17.0",

src/cli.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ let cli = sade("github-run-script")
1717
)
1818
.option("-s, --search", "A path to search for already-cloned repositories.")
1919
.option("-t, --terminate", "Terminate any spawned processes on error.")
20+
.option(
21+
"-q",
22+
"--quiet",
23+
"Do not make any output that isn't from the invoked scripts."
24+
)
2025
.option("--signal", "The signal to terminate a process with.")
2126
.action(handler);
2227

src/handler.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function terminateSpawnCache(signal: NodeJS.Signals = "SIGTERM") {
2727
export default async function handler(script: string, flags: CliFlags) {
2828
const { owner: defaultOwner, _: repoNames } = flags;
2929
let { search } = flags;
30+
const quiet = !!flags.quiet;
3031
const repos: RepoOwner[] = [];
3132
for (const repoName of repoNames) {
3233
try {
@@ -74,7 +75,10 @@ export default async function handler(script: string, flags: CliFlags) {
7475
for (const [path, directories] of scanDirectories) {
7576
for (const directory of directories) {
7677
if (repo === directory) {
77-
console.log(`Found ${repo} in ${path}`);
78+
if (!quiet) {
79+
console.log(`Found ${repo} in ${path}`);
80+
}
81+
7882
directoryMapping.set([owner, repo], `${path}/${repo}`);
7983
break;
8084
}
@@ -90,10 +94,18 @@ export default async function handler(script: string, flags: CliFlags) {
9094
// Deal wit the special case where we did not find a match. Time to clone.
9195
if (!directoryMapping.has([owner, repo])) {
9296
const destPath = `${tempDir}/${repo}`;
93-
console.log(`Cloning ${owner}/${repo} to ${destPath}`);
97+
if (!quiet) {
98+
console.log(`Cloning ${owner}/${repo} to ${destPath}`);
99+
}
100+
94101
const childProc = await spawn(
95102
"git",
96-
["clone", `https://github.com/${owner}/${repo}.git`, destPath],
103+
[
104+
"clone",
105+
"-q",
106+
`https://github.com/${owner}/${repo}.git`,
107+
destPath,
108+
],
97109
{ stdio: "inherit" }
98110
);
99111
await waitOnChildProcessToExit(childProc);

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface CliFlags extends BaseCliFlags {
66
owner?: string;
77
search?: string | string[];
88
terminate?: string | boolean;
9+
quiet?: string | boolean;
910
signal?: string;
1011
}
1112

0 commit comments

Comments
 (0)