Skip to content

Commit

Permalink
fix config in wrong env
Browse files Browse the repository at this point in the history
  • Loading branch information
Armaldio committed Apr 27, 2019
1 parent 64c408a commit a82f191
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
6 changes: 6 additions & 0 deletions src/template/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const deepmerge = require('deepmerge');

const base = require('./config-base');
const user = require('./config-user');

module.exports = deepmerge(base, user(base.env === 'production'));
1 change: 1 addition & 0 deletions src/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"electron": "3.1.6"
},
"dependencies": {
"deepmerge": "^3.2.0",
"fs-extra": "^7.0.1",
"get-port": "^4.2.0",
"serve-handler": "^5.0.8"
Expand Down
7 changes: 0 additions & 7 deletions src/template/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
# yarn lockfile v1


"@efc/core@latest":
version "0.0.2"
resolved "https://registry.yarnpkg.com/@efc/core/-/core-0.0.2.tgz#12a83f6d71014d8dcb5378cf632f3a83c8c6e513"
integrity sha512-WcCWRQzbCY2EVRNL4Y4TESeQWvQP/VuYbbf5c1Mn27iHDU/4DjgcF6eVXsWf1MkRmYYqZUPszDR4sYu4pCOxTQ==
dependencies:
deepmerge "^3.2.0"

"@types/node@^8.0.24":
version "8.10.45"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.45.tgz#4c49ba34106bc7dced77ff6bae8eb6543cde8351"
Expand Down
10 changes: 6 additions & 4 deletions src/utils/setupDir.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const extractZip = async (from, to) => new Promise((resolve, reject) => {
/**
* Prepare a sandboxed environment in tmp
* @param {Object} settings
* @param {function} log
* @param zipFile
* @returns {Promise<string>}
*/
Expand All @@ -42,10 +41,15 @@ module.exports = async (settings, zipFile = null) => {

// copy local files from template to tmpdir
shelljs.cp(path.join(__dirname, '../', 'template', 'main.js'), tmpDir.name);
shelljs.cp(path.join(__dirname, '../', 'template', 'config.js'), tmpDir.name);
shelljs.cp(path.join(__dirname, '../', 'template', 'preload.js'), tmpDir.name);
shelljs.cp(path.join(__dirname, '../', 'template', 'package.json'), tmpDir.name);

fs.writeFileSync(path.join(tmpDir.name, 'config.js'), `module.exports = ${JSON.stringify(settings, null, ' ')}`, 'utf8');
console.log(tmpDir.name);

shelljs.cp(path.join(process.cwd(), 'config.js'), path.join(tmpDir.name, 'config-user.js'));

fs.writeFileSync(path.join(tmpDir.name, 'config-base.js'), `module.exports = ${JSON.stringify(settings, null, ' ')}`, 'utf8');

if (zipFile) {
await extractZip(zipFile, tmpDir.name);
Expand All @@ -54,8 +58,6 @@ module.exports = async (settings, zipFile = null) => {
shelljs.cp('-R', path.join(process.cwd(), 'app', '*'), tmpDir.name);
}

// shelljs.cp(path.join(process.cwd(), 'config.js'), tmpDir.name);

// editing package.json
const pkg = fs.readFileSync(path.join(tmpDir.name, 'package.json'), 'utf8');
const pkgJson = JSON.parse(pkg);
Expand Down

0 comments on commit a82f191

Please sign in to comment.