Skip to content

Commit

Permalink
Moved JRE install location to storage folder so it persists between C…
Browse files Browse the repository at this point in the history
…LI updates
  • Loading branch information
acunniffe committed Nov 1, 2018
1 parent 881167b commit 633741e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "optic-cli",
"version": "2.0.5",
"version": "2.0.6",
"description": "",
"main": "lib/Cli.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/Cli.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
import config, {isDev} from "./config";
import program from 'commander'
import pJson from '../package'
import colors from 'colors'
Expand All @@ -18,7 +19,6 @@ import "regenerator-runtime/runtime";
import {setupFlow} from "./commands/SetupFlow";
import {track} from "./Analytics";
import platform from 'platform'
import config, {isDev} from "./config";
import updateNotifier from 'update-notifier'
import {jreName} from './jre/jre-install'
import fs from 'fs'
Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/control/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import config from '../../config'
import {serverStatus} from "../../optic/IsRunning";
import fs from 'fs'
import {track} from "../../Analytics";
import {javabinary} from "../../jre/javabinary";
const appRootPath = require('app-root-path').toString()

export const startCmd = {
Expand All @@ -24,7 +25,7 @@ export const startCmd = {
const out = fs.openSync(appRootPath+'/out.log', 'a');
const err = fs.openSync(appRootPath+'/out.log', 'a');

const binary = await config.runServerCmd.binary()
const binary = await javabinary()

const child = spawn(binary, config.runServerCmd.options, {
detached: true,
Expand Down
13 changes: 3 additions & 10 deletions cli/src/config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import {driver} from './jre/jre-install'
import "regenerator-runtime/runtime";

export const isDev = false

export default (() => {
const isDev = false

module.exports = (() => {
if (isDev) {
return {
runServerCmd: {
binary: async () => {
return new Promise(resolve => {
resolve('/usr/bin/java')
})
},
options: ['-jar', `${process.cwd()}/jars/server-assembly.jar`]
},
storageDirectory: process.cwd()+'/.optic-storage',
Expand All @@ -25,7 +18,6 @@ export default (() => {

return {
runServerCmd: {
binary: driver,
options: ['-jar', `${appRootPath}/${path}`]
},
storageDirectory: require('os').homedir()+'/.optic-storage',
Expand All @@ -35,3 +27,4 @@ export default (() => {

})()

module.exports.isDev = isDev
9 changes: 9 additions & 0 deletions cli/src/jre/javabinary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {isDev} from '../config'
import {driver} from './jre-install'
const devBinary = async () => {
return new Promise(resolve => {
resolve('/usr/bin/java')
})
}

export const javabinary = (isDev) ? devBinary : driver
3 changes: 1 addition & 2 deletions cli/src/jre/jre-install.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"use strict";

(function(){

const os = require('os');
Expand All @@ -12,7 +11,7 @@
const request = require('request');
const ProgressBar = require('progress');
const child_process = require('child_process');
const isDev = require('../config').isDev
const {storageDirectory} = require('../config')

const appRootPath = require('app-root-path')

Expand Down

0 comments on commit 633741e

Please sign in to comment.