Skip to content

Instantly share code, notes, and snippets.

@sigmasoldi3r
Last active March 31, 2017 10:28
Show Gist options
  • Save sigmasoldi3r/053c24570440cb4c6ba3dad107007452 to your computer and use it in GitHub Desktop.
Save sigmasoldi3r/053c24570440cb4c6ba3dad107007452 to your computer and use it in GitHub Desktop.
This invokes the express generator and generates a batch to run your server with debugging, this avoids you having to copy and paste what express says at the end.
@ECHO OFF
set app_title=Expresso - An express generator invoker
set script_title=NodeJS Express Server
set script_name=server.bat
title %app_title%
for %%f in (%cd%) do set workd=%%~nxf
echo Generating batch output for /%workd%/
(echo @ECHO OFF) > %script_name%
(echo title %script_title%) >> %script_name%
(echo rem Generated using %app_title%) >> %script_name%
(echo rem Argochamber Interactive 2017) >> %script_name%
(echo SET DEBUG=%workd%:* ^& npm start) >> %script_name%
echo ######################################################
echo ####### GENERATOR WILL CREATE YOUR EXPRESS APP #######
echo ######################################################
echo.
set YN=y
set /P YN=Install dependencies and make a test run? (Y/n): %=%
IF "%YN%"=="n" goto GENERATE_ONLY
IF "%YN%"=="N" goto GENERATE_ONLY
IF "%YN%"=="no" goto GENERATE_ONLY
IF "%YN%"=="No" goto GENERATE_ONLY
IF "%YN%"=="nO" goto GENERATE_ONLY
IF "%YN%"=="NO" goto GENERATE_ONLY
goto GENERATE_TEST
:GENERATE_TEST
echo Generating app and running dependency install...
call express %* -f
goto DEPS
:GENERATE_ONLY
echo Generating app only...
call express %* -f
goto DONE
:DONE
echo Done! Enjoy your app!
echo I'd personally recomend you using some sort of ide/editor like Atom, VSCode...
echo Open /%workd% dir and start editing your /%workd%/routes and /%workd%/views!
echo Have fun!
goto EXIT
:DEPS
call npm install
set ustart=true
goto DONE
:PREPARE_END
set ustart=false
echo Running express server...
call server
goto EXIT
:EXIT
if "%ustart%"=="true" goto PREPARE_END
@sigmasoldi3r
Copy link
Author

sigmasoldi3r commented Mar 31, 2017

Very simple usage, just place in a folder that you have in your %PATH% variable and then call inide a folder where you'd like to scaffold your express app. Then, run expresso to start scaffolding, you can specify other (but -f) parameters like: expresso --view=pug.

Note that -f is not permitted because is already specified inside the script.

Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment