You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

@ECHO off
:: 关闭命令行回显,不显示执行的命令本身,仅输出结果
GOTO start
:: 跳转到:start标签开始执行跳过函数定义部分
:find_dp0
:: 定义获取脚本所在目录的函数
SET dp0=%~dp0
:: %~dp0 是批处理特殊变量,获取当前脚本的绝对目录路径(包含末尾反斜杠)
EXIT /b
:: 退出函数,返回调用处
:start
:: 脚本执行的入口点
SETLOCAL
:: 开启局部局部环境变量模式,确保变量修改仅在当前脚本范围内生效
CALL :find_dp0
:: 调用:find_dp0函数获取脚本所在目录并赋值给dp0变量
:: 检查脚本目录下是否存在node.exe
IF EXIST "%dp0%\node.exe" (
:: 存在则使用本地node.exe路径
SET "_prog=%dp0%\node.exe"
) ELSE (
:: 不存在则使用系统全局node命令
SET "_prog=node"
:: 移除PATHEXT中的.JS扩展名避免系统误将node识别为JS文件
SET PATHEXT=%PATHEXT:;.JS;=;%
)
:: 结束局部环境执行browserslist的CLI脚本
:: title %COMSPEC% 重置命令行窗口标题(兼容部分环境)
:: "%_prog%" 是node执行路径本地/全局)
:: "%dp0%\..\browserslist\cli.js" 是browserslist的命令行入口脚本相对路径
:: %* 传递所有命令行参数给目标脚本
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\browserslist\cli.js" %*