Ver código fonte

fix(tauri.js) beforeDevCommand an beforeBuildCommand cwd as appDir (#583)

Lucas Fernandes Nogueira 5 anos atrás
pai
commit
50dcce8e24
2 arquivos alterados com 7 adições e 5 exclusões
  1. 1 1
      cli/tauri.js/src/helpers/spawn.ts
  2. 6 4
      cli/tauri.js/src/runner.ts

+ 1 - 1
cli/tauri.js/src/helpers/spawn.ts

@@ -11,7 +11,7 @@ export const spawn = (
   cmd: string,
   params: string[],
   cwd: string,
-  onClose: (code: number) => void
+  onClose?: (code: number) => void
 ): number => {
   log(`Running "${cmd} ${params.join(' ')}"`)
   log()

+ 6 - 4
cli/tauri.js/src/runner.ts

@@ -1,7 +1,7 @@
 import Inliner from '@tauri-apps/tauri-inliner'
 import toml, { JsonMap } from '@tauri-apps/toml'
 import chokidar, { FSWatcher } from 'chokidar'
-import { existsSync, readFileSync, writeFileSync, writeFile } from 'fs-extra'
+import { existsSync, readFileSync, writeFileSync } from 'fs-extra'
 import { JSDOM } from 'jsdom'
 import { debounce, template } from 'lodash'
 import path from 'path'
@@ -10,7 +10,7 @@ import * as net from 'net'
 import os from 'os'
 import { findClosestOpenPort } from './helpers/net'
 import * as entry from './entry'
-import { tauriDir } from './helpers/app-paths'
+import { tauriDir, appDir } from './helpers/app-paths'
 import logger from './helpers/logger'
 import onShutdown from './helpers/on-shutdown'
 import { spawn, spawnSync } from './helpers/spawn'
@@ -52,7 +52,9 @@ class Runner {
     if (!this.ranBeforeDevCommand && cfg.build.beforeDevCommand) {
       this.ranBeforeDevCommand = true // prevent calling it twice on recursive call on our watcher
       const [command, ...args] = cfg.build.beforeDevCommand.split(' ')
-      spawnSync(command, args, tauriDir)
+      spawn(command, args, appDir, code => {
+        process.exit(code)
+      })
     }
 
     const tomlContents = this.__getManifest()
@@ -194,7 +196,7 @@ class Runner {
   async build(cfg: TauriConfig): Promise<void> {
     if (cfg.build.beforeBuildCommand) {
       const [command, ...args] = cfg.build.beforeBuildCommand.split(' ')
-      spawnSync(command, args, tauriDir)
+      spawnSync(command, args, appDir)
     }
 
     const tomlContents = this.__getManifest()