Add Powershell script to start developement server (#63)

This commit is contained in:
Yannis Petitot
2019-10-19 20:29:12 +02:00
committed by GitHub
parent faa918feee
commit bb303e53c3
4 changed files with 56 additions and 5 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "beatconnect_client",
"version": "0.1.6",
"version": "0.1.7",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+5 -3
View File
@@ -9,6 +9,7 @@
"homepage": "./",
"scripts": {
"start": "node scripts/start.js",
"dev:win": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command ./scripts/start.ps1",
"build": "node scripts/build.js",
"test": "node scripts/test.js",
"lint": "npm run lint:prettier && npm run lint:es",
@@ -19,9 +20,9 @@
"lint:fix:es": "eslint --fix '**/*.{js,jsx,mjs,ts,tsx}'",
"go": "electron .",
"dist": "npm run build && npx npx electron-builder --win --linux --x64",
"dist-win": "npm run build && npx electron-builder build --win --x64",
"dist-linux": "npm run build && npx electron-builder build --linux --x64",
"dist-mac": "npm run build && npx electron-builder build --mac --x64",
"dist:win": "npm run build && npx electron-builder build --win --x64",
"dist:linux": "npm run build && npx electron-builder build --linux --x64",
"dist:mac": "npm run build && npx electron-builder build --mac --x64",
"dist:gh-publish": "npm run build && npx electron-builder build --win --linux --mac --ia32 --x64 -p always",
"electron-dev": "cross-env ELECTRON_START_URL=http://localhost:3000 electron ."
},
@@ -116,6 +117,7 @@
"postcss-normalize": "7.0.1",
"postcss-preset-env": "6.6.0",
"postcss-safe-parser": "4.0.1",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-app-polyfill": "^1.0.1",
"react-desktop": "^0.3.9",
+5 -1
View File
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
const { app, webContents } = require('electron');
const log = require('electron-log');
const isDev = require('electron-is-dev');
@@ -29,7 +30,10 @@ DownloadManager.register({
const main = () => {
let mainWindow = null;
console.log('readee');
if (isDev) {
console.log('Main process ready');
console.log('Waiting for dev server to show up');
}
mainWindow = new Window({
backgroundColor: '#121212',
+45
View File
@@ -0,0 +1,45 @@
cls
"$PSScriptRoot|npm start", "$PSScriptRoot|npm run electron-dev" | % {
$ScriptBlock = {
# accept the loop variable across the job-context barrier
param($pathWithCmd)
# Get working directory and command
$dir, $cmd = $pathWithCmd.split('|')
# Set job dir
Set-Location "$dir"
# Execute a command
Invoke-Expression $cmd
# Just wait for a bit...
Start-Sleep 5
}
$dir, $cmd = $_.split('|')
# pass the loop variable across the job-context barrier
Start-Job -name "$cmd" -ScriptBlock $ScriptBlock -ArgumentList $_
}
try {
While (Get-Job -State "Running") {
Get-Job | Receive-Job
}
}
catch {
Write-Error "Something went wrong"
}
finally {
Write-Warning "CTRL-C was used - Shutting down any running jobs before exiting the script. It can take some time."
Get-Job | Where-Object { $_.Name -like "npm *" } | Remove-Job -Force -Confirm:$False
[Console]::TreatControlCAsInput = $False
_Exit-Script -HardExit $True
}