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
: : 调用函数获取脚本所在目录, 赋值给dp0变量
: : 检查脚本目录下是否存在node.exe
IF EXIST " %dp0% \node.exe " (
: : 存在则使用本地node.exe路径
SET " _prog= %dp0% \node.exe "
) ELSE (
: : 不存在则使用系统全局node命令
SET " _prog=node "
: : 移除PATHEXT中的.JS扩展名, 避免系统误将node识别为JS文件( 适配Windows命令查找规则)
SET PATHEXT = %PATHEXT:;.JS;=;%
)
: : 结束局部环境, 执行flat的CLI脚本
: : title %COMSPEC% 重置命令行窗口标题(兼容部分环境)
: : "%_prog%" 是node执行路径( 本地/全局)
: : "%dp0%\..\flat\cli.js" 是flat工具命令行入口脚本的相对路径( 上级目录下的flat文件夹中)
: : %* 传递所有命令行参数给flat脚本
endLocal & goto #_undefined_# 2 > NUL || title %COMSPEC% & " %_prog% " " %dp0% \..\flat\cli.js " %*