mirror of
https://github.com/yldio/copilot.git
synced 2024-11-10 21:30:06 +02:00
fix(cp-frontend): gracefully handle multiple postinstall executions
checks if the webpack backup exists already before trying to create it
This commit is contained in:
parent
c45fb3ce41
commit
73899b2784
@ -41,6 +41,7 @@
|
||||
"unitcalc": "^1.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"apr-main": "^1.0.7",
|
||||
"babel-plugin-inline-react-svg": "^0.4.0",
|
||||
"babel-plugin-styled-components": "^1.1.4",
|
||||
"babel-preset-joyent-portal": "^1.0.0",
|
||||
@ -52,6 +53,7 @@
|
||||
"jest-matcher-utils": "^20.0.3",
|
||||
"jest-snapshot": "^20.0.3",
|
||||
"jest-styled-components": "^2.0.0",
|
||||
"mz": "^2.6.0",
|
||||
"npm-run-all": "^4.0.2",
|
||||
"react-scripts": "^1.0.0",
|
||||
"react-test-renderer": "^15.5.4",
|
||||
|
@ -1,7 +1,11 @@
|
||||
const fs = require('fs');
|
||||
const { readFile, writeFile, exists } = require('mz/fs');
|
||||
const main = require('apr-main');
|
||||
const path = require('path');
|
||||
|
||||
// TODO: this will need to happen for prod and test too
|
||||
|
||||
const enhancedConfigPath = path.join(__dirname, './webpack.config.dev.js');
|
||||
|
||||
const configPath = path.join(
|
||||
__dirname,
|
||||
'../node_modules/react-scripts/config/webpack.config.dev.js'
|
||||
@ -10,30 +14,15 @@ const orignalConfigPath = path.join(
|
||||
__dirname,
|
||||
'../node_modules/react-scripts/config/webpack.config.dev.original.js'
|
||||
);
|
||||
const enhancedConfigPath = path.join(__dirname, './webpack.config.dev.js');
|
||||
|
||||
// bit of healthy callback hell for making it spicy
|
||||
fs.readFile(configPath, (error, orignalConfig) => {
|
||||
if (error) {
|
||||
console.log('Original config read error', error);
|
||||
} else {
|
||||
fs.writeFile(orignalConfigPath, orignalConfig, error => {
|
||||
if (error) {
|
||||
console.log('Original config write error', error);
|
||||
} else {
|
||||
fs.readFile(enhancedConfigPath, (error, enhancedConfig) => {
|
||||
if (error) {
|
||||
console.log('Enhanced config read error', error);
|
||||
} else {
|
||||
fs.writeFile(configPath, enhancedConfig, error => {
|
||||
if (error) {
|
||||
console.log('Enhanced config write error', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
main((async () => {
|
||||
const orignalConfigPathExists = await exists(orignalConfigPath);
|
||||
|
||||
if (!orignalConfigPathExists) {
|
||||
const orignalConfig = await readFile(configPath, 'utf-8');
|
||||
await writeFile(orignalConfigPath, orignalConfig);
|
||||
}
|
||||
|
||||
const enhancedConfig = await readFile(enhancedConfigPath);
|
||||
await writeFile(configPath, enhancedConfig)
|
||||
})());
|
||||
|
@ -147,6 +147,10 @@ ansi-styles@^3.0.0:
|
||||
dependencies:
|
||||
color-convert "^1.0.0"
|
||||
|
||||
any-promise@^1.0.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f"
|
||||
|
||||
anymatch@^1.3.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507"
|
||||
@ -190,6 +194,12 @@ append-transform@^0.4.0:
|
||||
dependencies:
|
||||
default-require-extensions "^1.0.0"
|
||||
|
||||
apr-main@^1.0.7:
|
||||
version "1.0.7"
|
||||
resolved "https://registry.yarnpkg.com/apr-main/-/apr-main-1.0.7.tgz#4f2592e20cb236b09c3c3d98a95088fbcc5fad4d"
|
||||
dependencies:
|
||||
lodash.isfunction "^3.0.8"
|
||||
|
||||
aproba@^1.0.3:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.1.1.tgz#95d3600f07710aa0e9298c726ad5ecf2eacbabab"
|
||||
@ -4114,6 +4124,10 @@ lodash.isequal@^4.1.1:
|
||||
version "4.5.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
|
||||
|
||||
lodash.isfunction@^3.0.8:
|
||||
version "3.0.8"
|
||||
resolved "https://registry.yarnpkg.com/lodash.isfunction/-/lodash.isfunction-3.0.8.tgz#4db709fc81bc4a8fd7127a458a5346c5cdce2c6b"
|
||||
|
||||
lodash.isobject@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/lodash.isobject/-/lodash.isobject-3.0.2.tgz#3c8fb8d5b5bf4bf90ae06e14f2a530a4ed935e1d"
|
||||
@ -4359,6 +4373,14 @@ mute-stream@0.0.7:
|
||||
version "0.0.7"
|
||||
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
|
||||
|
||||
mz@^2.6.0:
|
||||
version "2.6.0"
|
||||
resolved "https://registry.yarnpkg.com/mz/-/mz-2.6.0.tgz#c8b8521d958df0a4f2768025db69c719ee4ef1ce"
|
||||
dependencies:
|
||||
any-promise "^1.0.0"
|
||||
object-assign "^4.0.1"
|
||||
thenify-all "^1.0.0"
|
||||
|
||||
nan@^2.3.0:
|
||||
version "2.6.2"
|
||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45"
|
||||
@ -6575,6 +6597,18 @@ text-table@0.2.0, text-table@^0.2.0, text-table@~0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
|
||||
|
||||
thenify-all@^1.0.0:
|
||||
version "1.6.0"
|
||||
resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726"
|
||||
dependencies:
|
||||
thenify ">= 3.1.0 < 4"
|
||||
|
||||
"thenify@>= 3.1.0 < 4":
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.0.tgz#e69e38a1babe969b0108207978b9f62b88604839"
|
||||
dependencies:
|
||||
any-promise "^1.0.0"
|
||||
|
||||
throat@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/throat/-/throat-3.0.0.tgz#e7c64c867cbb3845f10877642f7b60055b8ec0d6"
|
||||
|
Loading…
Reference in New Issue
Block a user