File tree Expand file tree Collapse file tree 2 files changed +18
-19
lines changed Expand file tree Collapse file tree 2 files changed +18
-19
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,10 @@ import {CLIError} from '@oclif/errors'
33import cli from 'cli-ux'
44import * as fs from 'fs'
55import * as fse from 'fs-extra'
6- import HTTP from 'http-call'
76import loadJSON from 'load-json-file'
87import * as path from 'path'
98import * as semver from 'semver'
9+ import { exec } from 'child_process'
1010
1111import { uniq , uniqWith } from './util'
1212import Yarn from './yarn'
@@ -240,20 +240,22 @@ export default class Plugins {
240240 }
241241
242242 private async npmHasPackage ( name : string ) : Promise < boolean > {
243- try {
244- const http : typeof HTTP = require ( 'http-call' ) . HTTP
245- const url = `${ this . npmRegistry } /${ name . replace ( '/' , '%2f' ) } `
246- await http . get ( url )
247- return true
248- } catch ( error ) {
249- this . debug ( error )
250-
251- if ( error . statusCode === 404 ) {
252- return false
253- }
254-
255- throw error
256- }
243+ return new Promise ( ( resolve , reject ) => {
244+ exec ( `npm show ${ name } dist-tags` , {
245+ encoding : 'utf-8' ,
246+ maxBuffer : 2048 * 2048 ,
247+ } , error => {
248+ if ( error ) {
249+ try {
250+ return resolve ( false )
251+ } catch {
252+ reject ( new Error ( `Could not run npm show for ${ name } ` ) )
253+ }
254+ } else {
255+ return resolve ( true )
256+ }
257+ } )
258+ } )
257259 }
258260
259261 private async savePJSON ( pjson : Config . PJSON . User ) {
Original file line number Diff line number Diff line change @@ -55,11 +55,8 @@ describe('command', () => {
5555 . it ( 'installs and uninstalls jdxcode/oclif-debug' )
5656
5757 test
58- . nock ( 'https://registry.npmjs.org' , api => api
59- . get ( '/@heroku-cli%2fplugin-stubbed' )
60- . reply ( 503 , '' ) )
6158 . command ( [ 'plugins:install' , 'stubbed' ] , { reset : true } )
62- . catch ( / H T T P E r r o r 5 0 3 / )
59+ . catch ( / 1 / )
6360 . stdout ( )
6461 . command ( [ 'plugins' ] , { reset : true } )
6562 . do ( output => expect ( output . stdout ) . to . equal ( 'no plugins installed\n' ) )
You can’t perform that action at this time.
0 commit comments