Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions dash_vite_plugin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ def _check_vite(self) -> bool:
"""
check_cmd = [self.npx_path, 'vite --help']

result = subprocess.run(check_cmd, capture_output=True, text=True, cwd=self.plugin_tmp_dir, env=self.node_env)
result = subprocess.run(
check_cmd, capture_output=True, text=True, cwd=self.plugin_tmp_dir, env=self.node_env, encoding='utf-8'
)
return result.returncode == 0

def _check_npm_package(self, package_name: str, package_type: Literal['devDependencies', 'dependencies']) -> bool:
Expand Down Expand Up @@ -225,7 +227,12 @@ def _install_vite(self) -> None:
'@vitejs/plugin-vue',
]
result = subprocess.run(
install_cmd, capture_output=True, text=True, cwd=self.plugin_tmp_dir, env=self.node_env
install_cmd,
capture_output=True,
text=True,
cwd=self.plugin_tmp_dir,
env=self.node_env,
encoding='utf-8',
)
if result.returncode != 0:
raise RuntimeError(result.stderr)
Expand Down Expand Up @@ -253,7 +260,12 @@ def _install_less(self) -> None:
'less',
]
result = subprocess.run(
install_cmd, capture_output=True, text=True, cwd=self.plugin_tmp_dir, env=self.node_env
install_cmd,
capture_output=True,
text=True,
cwd=self.plugin_tmp_dir,
env=self.node_env,
encoding='utf-8',
)
if result.returncode != 0:
raise RuntimeError(result.stderr)
Expand Down Expand Up @@ -281,7 +293,12 @@ def _install_sass(self) -> None:
'sass',
]
result = subprocess.run(
install_cmd, capture_output=True, text=True, cwd=self.plugin_tmp_dir, env=self.node_env
install_cmd,
capture_output=True,
text=True,
cwd=self.plugin_tmp_dir,
env=self.node_env,
encoding='utf-8',
)
if result.returncode != 0:
raise RuntimeError(result.stderr)
Expand Down Expand Up @@ -309,7 +326,12 @@ def _install_npm_packages(self) -> None:
f'{package.name}@{package.version}',
]
result = subprocess.run(
install_cmd, capture_output=True, text=True, cwd=self.plugin_tmp_dir, env=self.node_env
install_cmd,
capture_output=True,
text=True,
cwd=self.plugin_tmp_dir,
env=self.node_env,
encoding='utf-8',
)
if result.returncode != 0:
raise RuntimeError(result.stderr)
Expand Down Expand Up @@ -353,7 +375,12 @@ def init(self) -> Self:
if not self._check_npm_init():
init_cmd = [self.npm_path, 'init', '-y']
result = subprocess.run(
init_cmd, capture_output=True, text=True, cwd=self.plugin_tmp_dir, env=self.node_env
init_cmd,
capture_output=True,
text=True,
cwd=self.plugin_tmp_dir,
env=self.node_env,
encoding='utf-8',
)
if result.returncode != 0:
raise RuntimeError(result.stderr)
Expand Down Expand Up @@ -394,7 +421,7 @@ def build(self) -> Self:
build_cmd: List[str] = [self.npx_path, 'vite', 'build']

result = subprocess.run(
build_cmd, capture_output=True, text=True, cwd=self.plugin_tmp_dir, env=self.node_env
build_cmd, capture_output=True, text=True, cwd=self.plugin_tmp_dir, env=self.node_env, encoding='utf-8'
)

if result.returncode != 0:
Expand Down
Loading