Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dangling TTY handlers from stuck stdin #18

Merged
merged 1 commit into from
Jun 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type ManifestData = {
readonly name?: string;
};

type RegistryReesponse = {
type RegistryResponse = {
readonly ["dist-tags"]: {
latest: string;
};
Expand Down Expand Up @@ -85,6 +85,7 @@ async function main(
return new Map<string, ManifestData>(results.filter(typedBoolean));
},
{
discardStdin: false,
text: `Loading package.json ${fileMsg}`,
failText: `Failed to load package.json ${fileMsg}`,
successText: (results) =>
Expand All @@ -102,7 +103,8 @@ async function main(
const depMsg = t("dependency", depSet.size);
const depResults = await oraPromise(
async (ora) => {
// Rate-limit calls to `npm` to be safe in case we're pulling for a lot of dependencies
// Rate-limit calls to `npm` to be safe,
// in case we're pulling for a lot of dependencies
const limit = pLimit(300);
const results = await Promise.all(
Array.from(depSet, (d) => {
Expand All @@ -118,7 +120,7 @@ async function main(
}

try {
const res: RegistryReesponse = await body.json();
const res: RegistryResponse = await body.json();
const lastPublishTime = res.time[res["dist-tags"].latest];

let stale = false;
Expand All @@ -142,6 +144,7 @@ async function main(
return new Map<string, DependencyResult>(results.filter(typedBoolean));
},
{
discardStdin: false,
text: `Fetching metadata for ${depMsg}`,
failText: `Failed to fetch metadata for ${depMsg}`,
successText: (results) =>
Expand Down Expand Up @@ -203,7 +206,7 @@ yargs(hideBin(process.argv))
ora().warn("Using non-HTTPS registry URL");
}
return url;
} catch (error) {
} catch (_) {
throw new Error("Failed to parse registry URL!");
}
},
Expand Down