File tree Expand file tree Collapse file tree 7 files changed +40
-90
lines changed
Expand file tree Collapse file tree 7 files changed +40
-90
lines changed Original file line number Diff line number Diff line change 3636 "p-limit" : " ^6.0.0" ,
3737 "p-map" : " ^7.0.0" ,
3838 "process" : " 0.11.10" ,
39- "read" : " ^1 .0.7 " ,
39+ "read" : " ^4 .0.0 " ,
4040 "semver" : " ^7.6.2" ,
4141 "sprintf-js" : " ^1.1.2" ,
4242 "yargs" : " 17.7.2"
Original file line number Diff line number Diff line change 11import pLimit from "p-limit"
2- import read from "read"
2+ import { read } from "read"
33import { CommandModule } from "yargs"
44import { Reporter } from "../../reporter"
5- import { getGitHubOrgs } from "../../../definition"
6- import { Definition } from "../../../definition"
5+ import { Definition , getGitHubOrgs } from "../../../definition"
76import {
87 cleanupChangeSetItems ,
98 createChangeSetItemsForMembers ,
@@ -115,23 +114,12 @@ async function process(
115114 }
116115
117116 if ( execute && changes . length > 0 ) {
118- const cont = await new Promise < string > ( ( resolve , reject ) => {
119- read (
120- {
121- prompt : "Confirm you want to execute the changes [y/N]: " ,
122- timeout : 60000 ,
123- } ,
124- ( err , answer ) => {
125- if ( err ) {
126- // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
127- reject ( err )
128- }
129- resolve ( answer )
130- } ,
131- )
117+ const answer : string = await read ( {
118+ prompt : "Confirm you want to execute the changes [y/N]: " ,
119+ timeout : 60000 ,
132120 } )
133121
134- if ( cont === "y" || cont === "Y ") {
122+ if ( answer . toLowerCase ( ) === "y" ) {
135123 reporter . info ( "Executing changes" )
136124 await executeChangeSet ( github , changes , reporter )
137125 } else {
Original file line number Diff line number Diff line change 1- import read from "read"
1+ import { read } from "read"
22import { CommandModule } from "yargs"
33import { GitHubTokenCliProvider } from "../../../github/token"
44import { Reporter } from "../../reporter"
@@ -18,22 +18,11 @@ async function setToken({
1818 reporter . info (
1919 "https://github.com/settings/tokens/new?scopes=repo:status,read:repo_hook" ,
2020 )
21-
22- token = await new Promise < string > ( ( resolve , reject ) => {
23- read (
24- {
25- prompt : "Enter new GitHub API token: " ,
26- silent : true ,
27- } ,
28- ( err , answer ) => {
29- if ( err ) {
30- // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
31- reject ( err )
32- }
33- resolve ( answer )
34- } ,
35- )
21+ const inputToken = await read ( {
22+ prompt : "Enter new GitHub API token: " ,
23+ silent : true ,
3624 } )
25+ token = inputToken
3726 }
3827
3928 await tokenProvider . setToken ( token )
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import fs from "node:fs"
33import yaml from "js-yaml"
44import pLimit from "p-limit"
55import path from "path"
6- import read from "read"
6+ import { read } from "read"
77import { CommandModule } from "yargs"
88import { Config } from "../../../config"
99import { DefinitionFile , getRepos } from "../../../definition"
@@ -336,20 +336,9 @@ async function getExpectedRepos(
336336}
337337
338338async function getInput ( prompt : string ) : Promise < string > {
339- return new Promise < string > ( ( resolve , reject ) => {
340- read (
341- {
342- prompt,
343- timeout : 60000 ,
344- } ,
345- ( err , answer ) => {
346- if ( err ) {
347- // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
348- reject ( err )
349- }
350- resolve ( answer )
351- } ,
352- )
339+ return read ( {
340+ prompt,
341+ timeout : 60000 ,
353342 } )
354343}
355344
Original file line number Diff line number Diff line change 1- import read from "read"
1+ import { read } from "read"
22import { CommandModule } from "yargs"
33import { SnykTokenCliProvider } from "../../../snyk/token"
44import { Reporter } from "../../reporter"
@@ -16,22 +16,12 @@ async function setToken({
1616 if ( token === undefined ) {
1717 reporter . info ( "Need API token to talk to Snyk" )
1818 reporter . info ( "See https://app.snyk.io/account" )
19-
20- token = await new Promise < string > ( ( resolve , reject ) => {
21- read (
22- {
23- prompt : "Enter new Snyk API token: " ,
24- silent : true ,
25- } ,
26- ( err , answer ) => {
27- if ( err ) {
28- // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
29- reject ( err )
30- }
31- resolve ( answer )
32- } ,
33- )
19+ // noinspection UnnecessaryLocalVariableJS
20+ const inputToken = await read ( {
21+ prompt : "Enter new Snyk API token: " ,
22+ silent : true ,
3423 } )
24+ token = inputToken
3525 }
3626
3727 await tokenProvider . setToken ( token )
Original file line number Diff line number Diff line change 11import { execa , type Subprocess } from "execa"
22import fs from "node:fs"
33import { performance } from "perf_hooks"
4- import read from "read"
4+ import { read } from "read"
55import { Transform } from "stream"
66import { TestExecutor } from "./executor"
77import { Buffer } from "node:buffer"
@@ -500,19 +500,8 @@ export async function getDockerHostAddress(): Promise<string> {
500500export async function waitForEnterToContinue (
501501 prompt = "Press enter to continue" ,
502502) : Promise < void > {
503- return new Promise ( ( resolve , reject ) => {
504- read (
505- {
506- prompt,
507- silent : true ,
508- } ,
509- ( err ) => {
510- if ( err ) {
511- // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
512- reject ( err )
513- }
514- resolve ( )
515- } ,
516- )
503+ await read ( {
504+ prompt,
505+ silent : true ,
517506 } )
518507}
You can’t perform that action at this time.
0 commit comments