Skip to content

Commit

Permalink
Write 'published.js' module so script can know to use compiled vs. sr…
Browse files Browse the repository at this point in the history
…c code
  • Loading branch information
KyleAMathews committed Dec 22, 2015
1 parent a8c7967 commit 53c4e42
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ examples/biz-website/public/
examples/blog/public/
*.un~
dist
bin/published.js
2 changes: 1 addition & 1 deletion bin/build.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ packageJson = require '../package.json'

# Use compiled version of code when installed globally, otherwise use
# babelscript version.
if "dist" of packageJson
if require './published'
build = require '../dist/utils/build'
else
build = require '../lib/utils/build'
Expand Down
2 changes: 1 addition & 1 deletion bin/develop.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ packageJson = require '../package.json'

# Use compiled version of code when installed globally, otherwise use
# babelscript version.
if "dist" of packageJson
if require './published'
develop = require '../dist/utils/develop'
else
develop = require '../lib/utils/develop'
Expand Down
2 changes: 1 addition & 1 deletion bin/new.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ packageJson = require '../package.json'

# Use compiled version of code when installed globally, otherwise use
# babelscript version.
if "dist" of packageJson
if require './published'
initStarter = require '../dist/utils/init-starter'
else
initStarter = require '../lib/utils/init-starter'
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import webpack from 'webpack'
import StaticSiteGeneratorPlugin from 'static-site-generator-webpack-plugin'
import Config from 'webpack-configurator'
import packageJson from '../../package.json'
import published from '../../bin/published'

let gatsbyLib = /(gatsby.lib)/i
// If installed globally, look for "dist" directory instead.
if ('dist' in packageJson) {
if (published) {
gatsbyLib = /(gatsby.dist)/i
}

Expand Down
6 changes: 6 additions & 0 deletions scripts/prepublish.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
npm test
./scripts/build.sh

# Write out script so cli knows it's now published and should use the
# compiled code not Babel src code.
cat <<EOF >bin/published.js
module.exports = true
EOF

0 comments on commit 53c4e42

Please sign in to comment.