UNPKG

1.91 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../src/utils/detect-port-in-use-and-prompt.js"],"names":["detectPort","require","report","prompts","detectPortInUseAndPrompt","port","foundPort","detectedPort","catch","err","panic","log","response","type","name","message","initial","newPort","Error","module","exports"],"mappings":";;AAAA,MAAMA,UAAU,GAAGC,OAAO,CAAE,aAAF,CAA1B;;AACA,MAAMC,MAAM,GAAGD,OAAO,CAAE,yBAAF,CAAtB;;AACA,MAAME,OAAO,GAAGF,OAAO,CAAE,SAAF,CAAvB;;AAEA,MAAMG,wBAAwB,GAAG,MAAMC,IAAN,IAAc;AAC7C,MAAIC,SAAS,GAAGD,IAAhB;AACA,QAAME,YAAY,GAAG,MAAMP,UAAU,CAACK,IAAD,CAAV,CAAiBG,KAAjB,CAAuBC,GAAG,IAAIP,MAAM,CAACQ,KAAP,CAAaD,GAAb,CAA9B,CAA3B;;AACA,MAAIJ,IAAI,KAAKE,YAAb,EAA2B;AACzBL,IAAAA,MAAM,CAACS,GAAP,CAAY,0CAAyCN,IAAK,EAA1D;AACA,UAAMO,QAAQ,GAAG,MAAMT,OAAO,CAAC;AAC7BU,MAAAA,IAAI,EAAG,SADsB;AAE7BC,MAAAA,IAAI,EAAG,SAFsB;AAG7BC,MAAAA,OAAO,EAAG,wDAHmB;AAI7BC,MAAAA,OAAO,EAAE;AAJoB,KAAD,CAA9B;;AAMA,QAAIJ,QAAQ,CAACK,OAAb,EAAsB;AACpBX,MAAAA,SAAS,GAAGC,YAAZ;AACD,KAFD,MAEO;AACL,YAAM,IAAIW,KAAJ,CAAW,eAAX,CAAN;AACD;AACF;;AAED,SAAOZ,SAAP;AACD,CAnBD;;AAqBAa,MAAM,CAACC,OAAP,GAAiBhB,wBAAjB","sourcesContent":["const detectPort = require(`detect-port`)\nconst report = require(`gatsby-cli/lib/reporter`)\nconst prompts = require(`prompts`)\n\nconst detectPortInUseAndPrompt = async port => {\n let foundPort = port\n const detectedPort = await detectPort(port).catch(err => report.panic(err))\n if (port !== detectedPort) {\n report.log(`\\nSomething is already running at port ${port}`)\n const response = await prompts({\n type: `confirm`,\n name: `newPort`,\n message: `Would you like to run the app at another port instead?`,\n initial: true,\n })\n if (response.newPort) {\n foundPort = detectedPort\n } else {\n throw new Error(`USER_REJECTED`)\n }\n }\n\n return foundPort\n}\n\nmodule.exports = detectPortInUseAndPrompt\n"],"file":"detect-port-in-use-and-prompt.js"}
\No newline at end of file