Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Commit

Permalink
fix(code): allows src/index.server.js
Browse files Browse the repository at this point in the history
probably should allow the other extensions... ¯\_(ツ)_/¯

fixes #7
  • Loading branch information
saiichihashimoto committed Feb 10, 2019
1 parent 5b9754a commit 506d187
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 31 deletions.
2 changes: 1 addition & 1 deletion bin/Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
web: react-scripts start --color
server: nodemon --config $root/nodemon.json --exec babel-node src -- --config-file=$root/babel.config.js --no-babelrc
server: nodemon --config $root/nodemon.json --exec babel-node $src -- --config-file=$root/babel.config.js --no-babelrc
mongod: mkdir -p data/db && mongod --dbpath data/db --bind_ip 127.0.0.1
68 changes: 38 additions & 30 deletions bin/react-node-scripts-start.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node
const execa = require('execa');
const fs = require('fs');
const path = require('path');
const program = require('commander');
const { existsSync } = require('fs');
Expand All @@ -10,42 +11,49 @@ program
.option('--no-web')
.option('--no-server')
.action(
({ web, server, mongod }) => Promise.resolve()
// This triggers it to download the binary
.then(() => mongod && !existsSync(path.resolve(homedir(), '.mongodb-prebuilt')) && execa(
'mongod',
process.env.NODE_ENV === 'production' ?
() => execa(
'node',
[
'--version',
fs.existsSync('./lib/index.server.js') ? 'lib/index.server' : 'lib',
],
{
stdio: [process.stdin, process.stdout, process.stderr],
},
))
.then(() => execa(
'nf',
[
'start',
) :
({ web, server, mongod }) => Promise.resolve()
// This triggers it to download the binary
.then(() => mongod && !existsSync(path.resolve(homedir(), '.mongodb-prebuilt')) && execa(
'mongod',
[
'--version',
],
{
stdio: [process.stdin, process.stdout, process.stderr],
},
))
.then(() => execa(
'nf',
[
'start',

'--procfile', path.resolve(__dirname, 'Procfile'),
Object.entries({ web, server, mongod })
.map(([key, val]) => `${key}=${val ? 1 : 0}`)
.join(','),
],
{
env: {
MONGO_URL: mongod && 'mongodb://localhost:27017/database',
SKIP_PREFLIGHT_CHECK: true,
...process.env,
root: __dirname,
NODE_ENV: 'development',
PORT: process.env.PORT || 3000,
'--procfile', path.resolve(__dirname, 'Procfile'),
Object.entries({ web, server, mongod })
.map(([key, val]) => `${key}=${val ? 1 : 0}`)
.join(','),
],
{
env: {
MONGO_URL: mongod && 'mongodb://localhost:27017/database',
SKIP_PREFLIGHT_CHECK: true,
...process.env,
src: fs.existsSync('./src/index.server.js') ? 'src/index.server' : 'src',
PORT: process.env.PORT || 3000,
NODE_ENV: 'development',
root: __dirname,
},
stdio: [process.stdin, process.stdout, process.stderr],
},
stdio: [process.stdin, process.stdout, process.stderr],
},
))
.then(
({ stdout }) => stdout && console.log(stdout), // eslint-disable-line no-console
({ stderr }) => stderr && console.error(stderr), // eslint-disable-line no-console
),
)),
)
.parse(process.argv);
File renamed without changes.

0 comments on commit 506d187

Please sign in to comment.