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.
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变量设置为当前目录下的node.exe路径
SET " _prog= %dp0% \node.exe "
) ELSE (
: : 若不存在, 使用系统全局的node命令
SET " _prog=node "
: : 修改PATHEXT环境变量, 移除其中的.JS扩展名, 避免系统误将node识别为JS文件( 适配Windows命令查找规则)
SET PATHEXT = %PATHEXT:;.JS;=;%
)
: : 结束局部环境变量模式, 并执行autoprefixer脚本
: : title %COMSPEC% 用于重置命令行窗口标题(兼容部分环境)
: : "%_prog%" 是node的执行路径( 本地node.exe或全局node命令)
: : "%dp0%\..\autoprefixer\bin\autoprefixer" 是autoprefixer工具入口脚本的相对路径( 位于上级目录的autoprefixer文件夹中)
: : %* 传递所有命令行参数给autoprefixer脚本
endLocal & goto #_undefined_# 2 > NUL || title %COMSPEC% & " %_prog% " " %dp0% \..\autoprefixer\bin\autoprefixer " %*