#!/bin/sh basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; esac
read -p "Please enter a title:" title
if [ -x "$basedir/node" ]; then "$basedir/node""$basedir/../hexo/bin/hexo" new "$@""$title" ret=$? else node "$basedir/../hexo/bin/hexo" new "$@""$title" ret=$? fi exit$ret
创建hexo-new.cmd文件,用于Windows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
@ECHO off SETLOCAL CALL :find_dp0
IFEXIST "%dp0%\node.exe" ( SET "_prog=%dp0%\node.exe" ) ELSE ( SET "_prog=node" SET PATHEXT=%PATHEXT:;.JS;=;% )
set /p title=Please enter a title:
"%_prog%" "%dp0%\..\hexo\bin\hexo" new %* "%title%" ENDLOCAL EXIT /b %errorlevel% :find_dp0 SET dp0=%~dp0 EXIT /b
$exe="" if ($PSVersionTable.PSVersion -lt"6.0"-or$IsWindows) { # Fix case when both the Windows and Linux builds of Node # are installed in the same directory $exe=".exe" } $ret=0 if (Test-Path"$basedir/node$exe") { & "$basedir/node$exe""$basedir/../hexo/bin/hexo" new $args"$title" $ret=$LASTEXITCODE } else { & "node$exe""$basedir/../hexo/bin/hexo" new $args"$title" $ret=$LASTEXITCODE } exit$ret