Skip to content

Commit

Permalink
fix: copy xcode-project && pokemonLocation.gpx to tmp dir
Browse files Browse the repository at this point in the history
  • Loading branch information
iam4x committed Jul 15, 2016
1 parent c7c33a8 commit 0e92a66
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
27 changes: 22 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const electron = require('electron')
const { resolve } = require('path')
const { execSync } = require('child_process')

const { app } = electron
const { BrowserWindow } = electron

Expand All @@ -13,10 +16,24 @@ const createWindow = () => {
win.on('closed', () => { win = null })
}

app.on('ready', createWindow)
app.on('ready', () => {
const tmp = require('tmp')
tmp.dir((err, path) => {
if (err) throw err

global.tmpProjectPath = path
createWindow()

execSync(`cp -R ${resolve(__dirname, 'xcode-project')} ${resolve(path)}`)
execSync(`open -a xcode ${resolve(path, 'xcode-project/pokemon-webspoof.xcodeproj')}`)

// quit xcode && remove tmp directory on exit
app.on('before-quit', () => {
execSync('killall Xcode')
execSync(`rm -rf ${path}`)
})
})
})

app.on('window-all-closed', () => (process.platform !== 'darnwin') && app.quit())
app.on('activate', () => (win === null) && createWindow())

const { resolve } = require('path')
const { execSync } = require('child_process')
execSync(`open -a xcode ${resolve(__dirname, 'xcode-project/pokemon-webspoof.xcodeproj')}`)
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
"clean": "rm -rf ./dist/* ./pokemongo-webspoof-darwin-x64",
"build:code": "NODE_ENV=production webpack --config webpack.config.babel.js",
"build:electron": "electron-packager . pokemongo-webspoof --platform=darwin --arch=x64",
"open:xcode": "open ./xcode-project/pokemon-webspoof.xcodeproj/",
"open:app": "open ./pokemongo-webspoof-darwin-x64/pokemongo-webspoof.app",
"start": "npm run open:app && npm run open:xcode",
"build": "npm run clean && npm run build:code && npm run build:electron"
},
"bin": {
"pokemongo-webspoof": "./bin/pgws",
"pgws": "./bin/pgws"
},
"dependencies": {
"tmp": "0.0.28"
},
"devDependencies": {
"babel-eslint": "^6.1.2",
Expand Down
3 changes: 2 additions & 1 deletion src/models/user-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import settings from './settings.js'
const { writeFile } = window.require('fs')
const { resolve } = window.require('path')
const { exec } = window.require('child_process')
const { remote } = window.require('electron')

const userLocation = observable([ 0, 0 ])

Expand Down Expand Up @@ -40,7 +41,7 @@ const updateXcodeLocation = throttle(([ lat, lng ]) => {

if (settings.updateXcodeLocation.get()) {
// write `pokemonLocation.gpx` file fro xcode spoof location
const filePath = resolve(window.__dirname, 'pokemonLocation.gpx')
const filePath = resolve(remote.getGlobal('tmpProjectPath'), 'pokemonLocation.gpx')
writeFile(filePath, xcodeLocationData, async (error) => {
if (error) {
Alert.error(`
Expand Down

0 comments on commit 0e92a66

Please sign in to comment.