Skip to content

Commit

Permalink
🐛 Remove symlinks to fix twilio#11 (twilio#16)
Browse files Browse the repository at this point in the history
closes twilio#11 
closes twilio#7
  • Loading branch information
dkundel authored and andreasonny83 committed Nov 17, 2018
1 parent 0472553 commit 943c6c3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
39 changes: 28 additions & 11 deletions packages/flex-plugin/bin/check-start
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,38 @@ const { existsSync } = require('fs');
const { join } = require('path');
const chalk = require('chalk');
const { stripIndent } = require('common-tags');
const ncp = require('ncp').ncp;
const { promisify } = require('util');

const ERROR = chalk.bold.red('ERROR');
(async () => {
const cp = promisify(ncp);

const appConfigPath = join(process.cwd(), 'public', 'appConfig.js');
const ERROR = chalk.bold.red('ERROR');

const appConfigExists = existsSync(appConfigPath);
if (!appConfigExists) {
console.error(stripIndent`
const appConfigPath = join(process.cwd(), 'public', 'appConfig.js');

const appConfigExists = existsSync(appConfigPath);
if (!appConfigExists) {
console.error(stripIndent`
${ERROR} Could not find ${chalk.cyan('public/appConfig.js')}.
Check your ${chalk.cyan('public/')} directory for ${chalk.cyan(
'appConfig.example.js'
)}, copy it to ${chalk.cyan(
'appConfig.js'
)} and modify your Account SID and Service Base URL.
'appConfig.example.js'
)}, copy it to ${chalk.cyan(
'appConfig.js'
)} and modify your Account SID and Service Base URL.
`);
process.exit(1);
}
process.exit(1);
}

const indexSourcePath = join(__dirname,'..', 'dev_assets', 'index.html');
const indexTargetPath = join(process.cwd(), 'public', 'index.html');
try {
await cp(indexSourcePath, indexTargetPath, { clobber: true });
} catch (err) {
console.log(err);
console.error(`${ERROR} Failed to copy index.html file into public/ directory`);
}
})().catch(err => {
console.error(err);
});
3 changes: 2 additions & 1 deletion packages/flex-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"gitHead": "ca02b3d214e6dfa4277b6b69cbbb178783004edf",
"dependencies": {
"chalk": "^2.4.1",
"common-tags": "^1.8.0"
"common-tags": "^1.8.0",
"ncp": "^2.0.0"
},
"peerDependencies": {
"@twilio/flex-ui": "*"
Expand Down
10 changes: 0 additions & 10 deletions packages/react-app-rewire-flex-plugin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ const fs = require('fs');

process.env.PORT = process.env.PORT || 8080;

const indexHtmlSource = path.join('..', 'node_modules', 'flex-plugin', 'dev_assets', 'index.html');
const indexHtmlTarget = path.join('public', 'index.html');
try {
fs.symlinkSync(indexHtmlSource, indexHtmlTarget);
} catch (err) {
if (err.code !== 'EEXIST') {
console.error(err);
}
}

function overrideWebpack(config, env) {
//do stuff with the webpack config...
const pkg = readPkg.sync();
Expand Down

0 comments on commit 943c6c3

Please sign in to comment.