Commit 29d49a1 authored and committed Oct 29, 2021
1 parent 52cab97 commit 29d49a1 Copy full SHA for 29d49a1
File tree 1 file changed +15
-6
lines changed
packages/gatsby-dev-cli/src/utils
1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -60,16 +60,16 @@ exports.checkDepsChanges = async ({
60
60
// this allow us to not publish to local repository
61
61
// and save some time/work
62
62
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 )
66
66
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 } ` )
68
68
}
69
69
localPKGjson = JSON . parse ( response . body )
70
- } catch {
70
+ } catch ( e ) {
71
71
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 } `
73
73
)
74
74
return {
75
75
didDepsChanged : true ,
@@ -182,3 +182,12 @@ exports.checkDepsChanges = async ({
182
182
packageNotInstalled,
183
183
}
184
184
}
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