Skip to content

Commit 7572ca9

Browse files
Laurie BarthLaurie Barth
authored andcommitted
add an explicit error
1 parent ff9037d commit 7572ca9

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

packages/gatsby-plugin-theme-ui/gatsby-node.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
exports.onPreInit = (__, options) => {
22
let {themeModulePath} = options
3+
34
if(themeModulePath) {
5+
try {
46
options.themeModulePath = require(themeModulePath)
5-
}
7+
} catch {
8+
reporter.error(`It appears your theme dependency is not installed. Try running \`${generateInstallInstructions()} ${themeModulePath}\``)
9+
}
10+
}
11+
}
12+
13+
14+
function generateInstallInstructions() {
15+
const { getConfigStore } = require(`gatsby-core-utils`)
16+
17+
const packageMangerConfigKey = `cli.packageManager`
18+
const PACKAGE_MANGER = getConfigStore().get(packageMangerConfigKey) || `yarn`
19+
20+
const installKeyWord = PACKAGE_MANGER === `yarn` ? "add" : "install"
21+
22+
return `${PACKAGE_MANGER} ${installKeyWord}`
623
}
724

825
exports.createSchemaCustomization = ({ actions }) => {

packages/gatsby-plugin-theme-ui/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"license": "MIT",
77
"peerDependencies": {
88
"gatsby": "^2.13.1",
9-
"theme-ui": "^0.3.0"
9+
"theme-ui": "^0.3.0",
10+
"gatsby-core-utils": "^1.2.0"
1011
},
1112
"keywords": [
1213
"gatsby",

0 commit comments

Comments
 (0)