Skip to content

Commit

Permalink
add back installation and packaging as a script
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjacobbloom committed Jan 1, 2017
1 parent 049146b commit bf12469
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
2 changes: 0 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
var fs = require('fs-extra');
var http = require('http');
var path = require('path');
var spawn = require('child_process').spawn;
var express = require('express');
var MATUProjectBackup = require('./matu-project-backup.js');
var packager = require('electron-packager');
var archiver = require('archiver');

var CACHE_DIR = 'electron-cache';
Expand Down
52 changes: 52 additions & 0 deletions package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
var packager = require('electron-packager');
var spawn = require('child_process').spawn;

console.log('Running npm install...');
var isWin = /^win/.test(process.platform);
var npmProc = spawn(isWin ? 'npm.cmd' : 'npm', ['install'], { cwd: path.resolve(PLAYER_DIR) });

npmProc.stdout.on('data', function(data) {
console.log(data.toString());
});

npmProc.stderr.on('data', function(data) {
console.error(data.toString());
});

console.log('Running npm install for player/');
var npmPlayerProc = spawn('./installPlayer.sh');

npmPlayerProc.stdout.on('data', function(data) {
console.log(data.toString());
});

npmPlayerProc.stderr.on('data', function(data) {
console.error(data.toString());
});

var procFinished = [false, false];

npmProc.on('close', function(code) {
console.log('npm install exited with code ' + code);
procFinished[0] = true;
if(procFinished[0] && procFinished[1]) procsFinished();
});
npmPlayerProc.on('close', function(code) {
console.log('npm install for player/ exited with code ' + code);
procFinished[1] = true;
if(procFinished[0] && procFinished[1]) procsFinished();
});

function procsFinished() {
console.log('Creating electron package cache...');

packager({dir: PLAYER_DIR, all: true, out: CACHE_DIR}, function(error, paths) {
if(error) {
console.log('Packager error: ' + error)
throw error;
}
paths.forEach(function(apppath) {
console.log(' - packaged ' + apppath);
});
});
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
},
"main": "index.js",
"scripts": {
"start": "node index.js"
"start": "node index.js",
"package": "node package.js"
},
"dependencies": {
"archiver": "1.3.0",
Expand Down

0 comments on commit bf12469

Please sign in to comment.