Skip to content

Instantly share code, notes, and snippets.

@steve-jansen
Created June 24, 2013 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steve-jansen/5847465 to your computer and use it in GitHub Desktop.
Save steve-jansen/5847465 to your computer and use it in GitHub Desktop.
A script to run yeoman on Windows with dependencies managed in source tree. This script assumes that Ruby, NodeJS, and PhantomJS are under source control, while the yeoman and grunt node modules can be downloaded via npm.
:: Name: yeoman.cmd
:: Purpose: Convenience script to run yeoman on windows
:: Author: Steve Jansen
:: Revision: January 2013
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
SET /A ERR=0
PUSHD %~dps0\.. > NUL
SET project=%CD%
POPD > NUL
:: environmental variables for Yeoman dependendencies on the Ruby runtime and PhantomJS
SET PATH=%project%\lib\Ruby\win\bin;%PATH%
SET PATH=%project%\lib\node.js\win\;%PATH%
SET PHANTOMJS_BIN=%project%\lib\PhantomJs\win\phantomjs.exe
:: make the src/Client folder the working directory
PUSHD "%project%\src\Client" >NUL
IF NOT EXIST "%project%\lib\node.js\win\grunt.cmd" (
CALL :AutoRun
ECHO %~n0: installing grunt-cli globally
CALL "%project%\lib\node.js\win\npm.cmd" install -g grunt-cli
ECHO.
ECHO %~n0: installing node-gyp globally
CALL "%project%\lib\node.js\win\npm.cmd" install -g node-gyp
ECHO.
)
IF NOT EXIST ".\node_modules" (
CALL :AutoRun
ECHO %~n0: installing grunt locally
CALL "%project%\lib\node.js\win\npm.cmd" install grunt
ECHO .
ECHO %~n0: installing grunt project dependencies locally
CALL "%project%\lib\node.js\win\npm.cmd" install ws
ECHO .
CALL "%project%\lib\node.js\win\npm.cmd" install
ECHO.
)
ECHO %~n0: cleaning the src/Server/client folder
RMDIR /S /Q "%project%\src\Server\client" >NUL 2>&1
ECHO.
ECHO %~n0: running grunt build
"%project%\lib\node.js\win\grunt.cmd" build --no-color --gruntfile "%project%\src\Client\Gruntfile.js"
SET ERR=%ERRORLEVEL%
ECHO.
POPD >NUL
ENDLOCAL
EXIT /B %ERR%
:AutoRun
:: check for DOS AutoRun, which can break npm installs using node-gyp
REG QUERY "HKCU\Software\Microsoft\Command Processor" /v AutoRun >NUL 2>&1
IF "%ERRORLEVEL%" EQU "0" (
ECHO %~n0: WARNING - cmd.exe has AutoRun enabled for your user account. This may break npm or npm-gyp.
ECHO. Use regedit to disable HKCU\Software\Microsoft\Command Processor\AutoRun
)
REG QUERY "HKLM\Software\Microsoft\Command Processor" /v AutoRun >NUL 2>&1
IF "%ERRORLEVEL%" EQU "0" (
ECHO %~n0: WARNING - cmd.exe has AutoRun enabled for all users. This may break npm or npm-gyp.
ECHO. Use regedit to disable HKLM\Software\Microsoft\Command Processor\AutoRun
)
EXIT /B 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment