Skip to content

Commit

Permalink
fix existing folder bug on packaging + installing
Browse files Browse the repository at this point in the history
  • Loading branch information
w-raken committed Nov 13, 2017
1 parent 9d3f1c6 commit 6def00d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
19 changes: 19 additions & 0 deletions builder/installer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const path = require('path');
const json = require(path.resolve('./package.json'));
const exec = require('child_process').exec;
const execSync = require('child_process').execSync;
const fs = require('fs');

// See available platform and arch here :
// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md
Expand Down Expand Up @@ -32,6 +34,11 @@ const linuxConfig = {

switch (process.env.NODE_OS) {
case "mac":
if (fs.existsSync('./mac_installer')) {
console.log('Removing existing ./mac_installer...');
execSync("rm -rf mac_installer", { maxBuffer: 1024 * 2048 });
console.log('Successfully removed ./mac_installer/');
}
console.log('Creating mac installer...');
exec("mkdir mac_installer && electron-installer-dmg ./mac_packager/" + json.name + "-" + spec['platform']['2'] + "-" + spec['arch']['2'] + "/" + json.name + ".app " + json.name + " --out=mac_installer --overwrite && rm -rf mac_packager", (error) => {
if (!error) {
Expand All @@ -45,6 +52,12 @@ switch (process.env.NODE_OS) {
case "linux":
const linuxInstaller = require('electron-installer-debian');

if (fs.existsSync('./linux_installer')) {
console.log('Removing existing ./linux_installer...');
execSync("rm -rf linux_installer", { maxBuffer: 1024 * 2048 });
console.log('Successfully removed ./linux_installer/');
}

console.log('Creating linux installer...');

linuxInstaller(linuxConfig, (error) => {
Expand All @@ -68,6 +81,12 @@ switch (process.env.NODE_OS) {
name: json.name.replace(/-/g, "_")
};

if (fs.existsSync('./win_installer')) {
console.log('Removing existing ./win_installer...');
execSync("del /s /q win_installer && rmdir /s /q win_installer", { maxBuffer: 1024 * 2048 });
console.log('Successfully removed ./win_installer/');
}

console.log('Creating windows installer...');

resultPromise = electronInstaller.createWindowsInstaller(settings);
Expand Down
19 changes: 18 additions & 1 deletion builder/packager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const path = require('path');
const json = require(path.resolve('./package.json'));
const exec = require('child_process').exec;
const execSync = require('child_process').execSync;
const fs = require('fs');

// See available platforms and archs here :
// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md
Expand All @@ -20,7 +22,12 @@ const spec = {

switch (process.env.NODE_OS) {
case "mac":
console.log('Creating mac packager...');
if (fs.existsSync('./mac_packager')) {
console.log('Removing existing ./mac_packager...');
execSync("rm -rf mac_packager", { maxBuffer: 1024 * 2048 });
console.log('Successfully removed ./mac_packager/');
}
console.log('Creating mac packager...');
exec("cross-env NODE_ENV=prod webpack && electron-packager . --overwrite --platform=" + spec['platform']['2'] + " --arch=" + spec['arch']['2'] + " --prune=true --out=mac_packager --icon=builder/icons/mac/icon.icns", (error) => {
if (!error) {
console.log('Successfully created packager at ./mac_packager/');
Expand All @@ -30,6 +37,11 @@ switch (process.env.NODE_OS) {
});
break;
case "linux":
if (fs.existsSync('./linux_packager')) {
console.log('Removing existing ./linux_packager...');
execSync("rm -rf linux_packager", { maxBuffer: 1024 * 2048 });
console.log('Successfully removed ./linux_packager/');
}
console.log('Creating linux packager...');
exec("cross-env NODE_ENV=prod webpack && electron-packager . --overwrite --platform=" + spec['platform']['3'] + " --arch=" + spec['arch']['2'] + " --prune=true --out=linux_packager --icon=builder/icons/linux/icon.png", (error) => {
if (!error) {
Expand All @@ -40,6 +52,11 @@ switch (process.env.NODE_OS) {
});
break;
case "win":
if (fs.existsSync('./win_packager')) {
console.log('Removing existing ./win_packager...');
execSync("del /s /q linux_packager && rmdir /s /q linux_packager", { maxBuffer: 1024 * 2048 });
console.log('Successfully removed ./win_packager/');
}
console.log('Creating windows packager...');
exec("cross-env NODE_ENV=prod webpack && electron-packager . --overwrite --platform=" + spec['platform']['1'] + " --arch=" + spec['arch']['2'] + " --prune=true --out=win_packager --icon=builder/icons/win/icon.ico", (error) => {
if (!error) {
Expand Down

0 comments on commit 6def00d

Please sign in to comment.