Skip to content

@bmcminn /BASH: node-webkit.bash
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A bunch of helper functions and short hand methods that I find useful in developing Node-Webkit applications.
#!/bin/sh
#
#
# _____ _ _ _ _ _ _ _ _
# | | |___ _| |___ ___| | | |___| |_| |_|_| |_
# | | | | . | . | -_|___| | | | -_| . | '_| | _|
# |_|___|___|___|___| |_____|___|___|_,_|_|_|
#
# _____ _ _____ _
# | __ |___ ___| |_ | | |___| |___ ___ ___ ___
# | __ -| .'|_ -| | | | -_| | . | -_| _|_ -|
# |_____|__,|___|_|_| |__|__|___|_| _|___|_| |___|
# |_|
#
# =============================================================================
#
# This file contains helper functions and shorthands that aid with
# Node-Webkit app development on Windows and UNIX machines.
#
#
# NOTE FOR WINDOWS USERS:
# ---------------------------------------------
#
# I would definitely suggest for windows users to download
# Git Bash [https://code.google.com/p/msysgit/downloads/list?q=label:Featured] if you haven't already
#
#
# INSTALLATION:
# ---------------------------------------------
#
# - Save this file to a common location for your bash/shell scripts and be sure
# to use the proper file extension for your platform.
#
# - Change the [#!/bin/xxx] reference up top for your OS' preferred declaration
# ex: #!/bin/bash <- UNIX
# #!/bin/sh <- Windows
#
# - Add this shell script as a 'source' reference in your bash .profile
# ex: source "path/to/this/node-webkit.sh"
#
# - Change these values to match your folder system setup
#
APPPACKAGE="app.nw";
APPSDIR="/c/apps";
NWDIR="/c/apps/__node-webkit";
# Example of my /apps folder structure
# ---------------------------------------------
#
# /C
# - /apps
# - /__node-webkit
# - [downloaded node-webkit build files]
# - /projectName
# - /projectName2
# - app.nw
#
# NODE WEBKIT HELPER FUNCTIONS
# ============================
#
# Navigate into your /apps directory
# ---------------------------------------------
#
# - Pass a name of the project you want to navigate into
# ex: apps awesomesauce -> /c/apps/awesomesauce :D
function nw-apps() {
cd $APPSDIR;
if [ $1 ]
then
cd $1;
fi
dir;
}
# This inits the local dev Node-Webkit instance with the most
# recent app.nw build located in the /c/apps/app.nw directory
# ---------------------------------------------
function nw-init() {
echo "[Initializing] $APPPACKAGE";
echo "running...";
$NWDIR/nw $APPSDIR/$APPPACKAGE
echo "[Terminated] $APPPACKAGE";
}
# Package your application assets and run Node-Webkit
# ---------------------------------------------
#
# This should be called from inside an "/apps/[project directory]/"
#
function nw-package() {
if [ -e $APPSDIR/$APPPACKAGE ]
then
rm $APPSDIR/$APPPACKAGE;
fi
zip -r $APPSDIR/$APPPACKAGE * -x .*;
nw-init;
}
# LICENSE
# ---------------------------------------------
#
# The MIT License (MIT)
#
# Copyright (c) 2013 Brandtley McMinn
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
@SirZach

Great script, thanks a lot for posting this!

I have a question about zip -r $APPSDIR/$APPPACKAGE * -x .*;

This will package up all the node_modules files, do you find this to be an issue? I have been able to get away not needing all those files zipped up. It lessens the size and boot-up time of the app.

@bmcminn
Owner

Hey @SirZach, I wrote this as a means of getting started with NW dev and needed a way to automate the packaging process, so I hadn't done a whole lot of testing on what files were needed at the time. I haven't dabbled in Node Webkit much since I wrote this script, and I feel this script has been supplanted by more configurable build tools like node-webkit-builder and the various build systems that consume it (grunt, gulp, npm/node in general).

Thanks for the kudos, and happy development :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.