### 变量名=变量值
// set 变量名=变量值
set currentPath=%~dp0
### 变量名=变量值
currentPath=$(cd "$(dirname "$0")"; pwd)
%currentPath%
// $currentPath 也可
${currentPath}
"%currentPath%\dist"
"%{currentPath}/dist"
rd /S /Q "%currentPath%\dist\scripts"
*shell
rm -rf ${currentPath}/dist/scripts
if exist "%webapp%\resources\scripts" ( rd /S /Q "%webapp%\resources\scripts")
if [ -d ${webapp}/resources/scripts ]
then
rm -rf ${webapp}/resources/scripts
fi
move "%currentPath%\src\resources\scripts" "%currentPath%\dist\"
mv "${currentPath}/src/resources/scripts" "${currentPath}/dist/"
//这里有个大坑哦,直接 npm run build 或其他调用,会自动退出脚本。所以用 call
call npm run build
npm run build
bat demo : 点击下载
shell demo : 点击下载
之前,写过不少脚本,但是每次写过就掉在一边了,下次要用都是找不着的那种。 很尴尬! 所以,在这里写下来。