Skip to content

Instantly share code, notes, and snippets.

@jganoff
Last active August 29, 2015 14:13
Show Gist options
  • Save jganoff/2917c2f2501b8f5bd9a1 to your computer and use it in GitHub Desktop.
Save jganoff/2917c2f2501b8f5bd9a1 to your computer and use it in GitHub Desktop.
PebbleJS in Node
# Clone PebbleJS' repo. This is the basis for all PebbleJS apps and includes
# libraries such as 'ajax', and 'ui'.
git clone git@github.com:pebble/pebblejs.git
# Tell Node where to find the PebbleJS modules
export NODE_PATH=$NODE_PATH:$(pwd)/pebblejs/js:$(pwd)/pebblejs/js/lib
# Pull down the XMLHttpRequest module into the current working directory.
# The 'ajax' module requires this.
npm install xmlhttprequest
# Load Pebble's Best Practices guide as a test that ajax works.
node -e "
// Make XMLHttpRequest available globally.
var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
// Test the 'ajax' module from PebbleJS.
require('ajax')(
{
url: 'http://developer.getpebble.com/guides/best-practices/'
},
function(data) { console.log(data); },
function(error) { console.log(error); }
);
"
# Now you have a working Node environment that mimics what PebbleJS has
# access to - minus the UI components. This is enough for my prototyping
# for now; hopefully yours to. I may put together a UI simulator if I
# need to. Until then, happy hacking!
# - Jordan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment