Skip to content

Commit

Permalink
fix: support Windows batch file
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Jun 9, 2021
1 parent ed69546 commit f1c7d25
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 101 deletions.
2 changes: 1 addition & 1 deletion examples/vue-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"build": "vite build",
"serve": "vite preview"
},
"dependencies": {
Expand Down
73 changes: 0 additions & 73 deletions src/cliMode.ts

This file was deleted.

21 changes: 8 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { spawn } from 'child_process'
import npmRunPath from 'npm-run-path'
import os from 'os'
import { ConfigEnv, Plugin } from 'vite'
import { PluginOptions } from './types'

import { createDiagnosis } from './apiMode'
import { tscProcess } from './cliMode'
import { PluginOptions } from './types'

export default function Plugin(userOptions?: Partial<PluginOptions>): Plugin {
const checker = userOptions?.checker ?? 'tsc'
Expand All @@ -14,18 +14,12 @@ export default function Plugin(userOptions?: Partial<PluginOptions>): Plugin {

return {
name: 'ts-checker',
config: (config, { command, mode }) => {
config: (config, { command }) => {
viteMode = command
if (mode === 'cli') {
tscProcess.config(config)
} else {
diagnose = createDiagnosis({
root: userOptions?.root,
tsconfigPath: userOptions?.tsconfigPath,
})

diagnose.config(config)
}
diagnose = createDiagnosis({
root: userOptions?.root,
tsconfigPath: userOptions?.tsconfigPath,
})
},
buildStart: (options) => {
if (viteMode === 'build') {
Expand All @@ -39,6 +33,7 @@ export default function Plugin(userOptions?: Partial<PluginOptions>): Plugin {
cwd: process.cwd(),
stdio: 'inherit',
env: localEnv,
shell: os.platform() === 'win32',
})

if (enableBuild) {
Expand Down
14 changes: 0 additions & 14 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ export interface PluginOptions {
* Same as [Vite config](https://vitejs.dev/config/#root)
*/
overlay: boolean
/**
* [WIP]
* 'cli': use `tsc --noEmit` or `vue-tsc --noEmit`
* - No overlay support
* - Original console output
*
* 'api': use TypeScript programmatic API
* - Support overlay
* - Almost the same console output as original
*
* @defaultValue
* if 'vueTsc' is true, then force set to 'cli', otherwise default to 'api'
*/
// mode: 'cli' | 'api'
/**
* Root path to find tsconfig file
* @defaultValue
Expand Down

0 comments on commit f1c7d25

Please sign in to comment.