fix(tauri.js) exit dev when running as admin, fixes #781 (#839)

This commit is contained in:
Lucas Fernandes Nogueira
2020-07-15 20:05:07 -03:00
committed by GitHub
parent 031d5fdafe
commit 17800571fe
8 changed files with 38 additions and 24 deletions

View File

@@ -0,0 +1,5 @@
---
"tauri.js": patch
---
Prevent running the `dev` pipeline when running with administrator privileges.

View File

@@ -3,10 +3,10 @@ name: clippy and fmt check
on:
pull_request:
paths:
- .github/workflows/core-lint-fmt.yml
- ./tauri/**
- ./tauri-utils/**
- ./tauri-api/**
- '.github/workflows/core-lint-fmt.yml'
- './tauri/**'
- './tauri-utils/**'
- './tauri-api/**'
jobs:
workspace_clippy_fmt_check:

View File

@@ -3,8 +3,8 @@ name: eslint check
on:
pull_request:
paths:
- .github/workflows/js-lint.yml
- ./cli/tauri.js/**
- '.github/workflows/js-lint.yml'
- './cli/tauri.js/**'
jobs:
eslint-check:

View File

@@ -3,8 +3,8 @@ name: test bundler
on:
pull_request:
paths:
- .github/workflows/test-bundler.yml
- ./cli/tauri-bundler/**
- '.github/workflows/test-bundler.yml'
- './cli/tauri-bundler/**'
env:
RUST_BACKTRACE: 1

View File

@@ -3,11 +3,11 @@ name: test core
on:
pull_request:
paths:
- .github/workflows/test-core.yml
- ./cli/**
- ./tauri/**
- ./tauri-api/**
- ./tauri-utils/**
- '.github/workflows/test-core.yml'
- './cli/**'
- './tauri/**'
- './tauri-api/**'
- './tauri-utils/**'
env:
RUST_BACKTRACE: 1

View File

@@ -1,5 +1,7 @@
# Webpack output
# Build output
/dist
/api
# Logs
logs
@@ -62,13 +64,3 @@ typings/
debug.log
package-lock.json
.vscode/settings.json
#api
api/*
# Tauri output
bundle.json
config.json
# rust compiled folders
target

View File

@@ -0,0 +1 @@
[bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544");

View File

@@ -2,6 +2,13 @@ import { TauriConfig } from 'types'
import { merge } from 'webpack-merge'
import Runner from '../runner'
import getTauriConfig from '../helpers/tauri-config'
import logger from '../helpers/logger'
import chalk from 'chalk'
import { platform } from 'os'
import { resolve } from 'path'
import { sync as spawnSync } from 'cross-spawn'
const error = logger('tauri:dev', chalk.red)
interface DevResult {
promise: Promise<void>
@@ -9,6 +16,15 @@ interface DevResult {
}
module.exports = (config: TauriConfig): DevResult => {
if (platform() === 'win32') {
const child = spawnSync('powershell', [resolve(__dirname, '../../scripts/is-admin.ps1')])
const response = String(child.output[1]).replace('\n', '').trim()
if (response === 'True') {
error('Administrator privileges detected. Tauri doesn\'t work when running as admin, see https://github.com/Boscop/web-view/issues/96')
process.exit(1)
}
}
const tauri = new Runner()
const tauriConfig = getTauriConfig(
merge(