Skip to content

Instantly share code, notes, and snippets.

@phdesign
Created November 9, 2015 09:48
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 phdesign/d46425bc4a2b72cd4802 to your computer and use it in GitHub Desktop.
Save phdesign/d46425bc4a2b72cd4802 to your computer and use it in GitHub Desktop.
Using Grunt with pebble build
/*
* Example jshint configuration file for Pebble development.
* Adapted from http://developer.getpebble.com/blog/2014/01/12/Using-JSHint-For-Pebble-Development/
*
* Check out the full documentation at http://www.jshint.com/docs/options/
*/
{
// Declares the existence of a global 'Pebble' object
"globals": { "Pebble" : true },
// And standard objects (XMLHttpRequest and console)
"browser": true,
"devel": true,
"node": true,
// Do not mess with standard JavaScript objects (Array, Date, etc)
"freeze": true,
// Do not use eval! Keep this warning turned on (ie: false)
"evil": false,
/*
* The options below are more style/developer dependent.
* Customize to your liking.
*/
// Do not allow blocks without { }
"curly": false,
// Prohibits the use of immediate function invocations without wrapping them in parentheses
"immed": true,
// Enforce indentation
"indent": true,
// Do not use a variable before it's defined
"latedef": "nofunc",
// Spot undefined variables
"undef": "true",
// Spot unused variables
"unused": "true",
// Require capitalization of all constructor functions e.g. `new F()`
"newcap" : true,
// Enforce use of single quotes (') everywhere
"quotmark" : "single",
// Tolerate use of `== null`
"eqnull" : false,
// Supress dot notation warnings (e.g. allow obj['prop'])
"sub" : true
}
#pragma once
#define LONG_NAME "<%= config.info.longName %>"
#define VERSION_LABEL "<%= config.info.versionLabel %>"
#define UUID "<%= config.info.uuid %>"
<% for (prop in config.info.appKeys) {
%>#define <%= prop %> <%= config.info.appKeys[prop] %>
<% } %>
<% for (prop in config.keys) {
%>#define KEY_<%= prop %> <%= config.keys[prop] %>
<% } %>
module.exports = function(grunt) {
var appConfig = {
info: grunt.file.readJSON('appinfo.json'),
keys: grunt.file.readJSON('keys.json')
};
grunt.initConfig({
config: appConfig,
copy: {
main: {
options: {
process: function (content, path) {
return grunt.template.process(content);
}
},
files: {
'src/appinfo.h': ['src/appinfo.tpl.h']
}
},
},
jshint: {
files: [
'Gruntfile.js',
'src/js/**/*.js'
],
options: {
jshintrc: true
}
},
browserify: {
build: {
src: [
'src/js/**/*.js',
'!src/js/pebble-js-app.js'
],
dest: 'src/js/pebble-js-app.js'
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask('default', ['copy', 'jshint', 'browserify']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment