Skip to content

Commit

Permalink
fix(index): verify the presence of babel-core inside devDeps and deps…
Browse files Browse the repository at this point in the history
… too
  • Loading branch information
GabeDuarteM committed Sep 2, 2018
1 parent 1551073 commit f7e758d
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
#!/usr/bin/env node
import get from "lodash.get"
import { logMessage } from "./utils"

const resolutions = require(`${process.cwd()}/package.json`).resolutions
const pkg = require(`${process.cwd()}/package.json`)

if (!resolutions || resolutions["babel-core"] !== "^7.0.0-bridge.0") {
console.warn(`
[gd-scripts]: babel-core should be set to bridge mode to avoid errors. To do that, add the following code to your package.json:
const babelCoreBridgeVersion = "^7.0.0-bridge.0"

"resolutions": {
"babel-core": "^7.0.0-bridge.0"
},
const babelCoreDevDep = get(pkg, "devDependencies.babel-core")
const babelCoreDep = get(pkg, "dependencies.babel-core")
const babelCoreResolutions = get(pkg, "resolutions.babel-core")

`)
if (
(!babelCoreDevDep && !babelCoreDep && !babelCoreResolutions) ||
(babelCoreDevDep && babelCoreDevDep !== babelCoreBridgeVersion) ||
(babelCoreDep && babelCoreDep !== babelCoreBridgeVersion) ||
(babelCoreResolutions && babelCoreResolutions !== babelCoreBridgeVersion)
) {
logMessage(
"babel-core should be set to bridge mode to avoid errors. To do that run 'npm i -D babel-core@^7.0.0-bridge.0'",
)
}

require("./run-script")

0 comments on commit f7e758d

Please sign in to comment.