File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
packages/gatsby-dev-cli/src/utils Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -60,16 +60,16 @@ exports.checkDepsChanges = async ({
6060 // this allow us to not publish to local repository
6161 // and save some time/work
6262 try {
63- const response = await got (
64- `https://unpkg.com/${ packageName } /package.json`
65- )
63+ const version = getPackageVersion ( packageName )
64+ const url = `https://unpkg.com/${ packageName } @ ${ version } /package.json`
65+ const response = await got ( url )
6666 if ( response ?. statusCode !== 200 ) {
67- throw new Error ( `No response or non 200 code` )
67+ throw new Error ( `No response or non 200 code for ${ url } ` )
6868 }
6969 localPKGjson = JSON . parse ( response . body )
70- } catch {
70+ } catch ( e ) {
7171 console . log (
72- `'${ packageName } ' doesn't seem to be installed and is not published on NPM.`
72+ `'${ packageName } ' doesn't seem to be installed and is not published on NPM. Error: ${ e . message } `
7373 )
7474 return {
7575 didDepsChanged : true ,
@@ -182,3 +182,12 @@ exports.checkDepsChanges = async ({
182182 packageNotInstalled,
183183 }
184184}
185+
186+ function getPackageVersion ( packageName ) {
187+ const projectPackageJson = JSON . parse (
188+ fs . readFileSync ( `./package.json` , `utf-8` )
189+ )
190+ const { dependencies = { } , devDependencies = { } } = projectPackageJson
191+ const version = dependencies [ packageName ] || devDependencies [ packageName ]
192+ return version || `latest`
193+ }
You can’t perform that action at this time.
0 commit comments