public
Last active

A bunch of helper functions and short hand methods that I find useful in developing Node-Webkit applications.

  • Download Gist
BASH: node-webkit.bash
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
#!/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.
#

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.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.