Skip to content

Instantly share code, notes, and snippets.

@gausby
Last active December 14, 2015 08:29
Show Gist options
  • Save gausby/5058334 to your computer and use it in GitHub Desktop.
Save gausby/5058334 to your computer and use it in GitHub Desktop.
git init ... How I currently start off my personal Node projects. Folder structure: README.md ; /lib/ ; /package.json ; /.jshintrc ; /Gruntfile.js ; /.gitignore ; /test/ ; /test/buster.js ; Discuss! (Files can't be in subdirectories in gists, but every config file, except for the buster.js file, is located in the root of the project--the buster.…
/node_modules/
/docs/
/benchmarks/results.csv
{
"node": true,
"es5": true,
"strict": true,
"globalstrict": true,
"validthis": true,
"trailing": true,
"indent": 4,
"curly": true,
"newcap": true,
"quotmark": "single"
}
/* global module */
'use strict';
var config = module.exports;
config.node = {
env: 'node',
tests: ['**/*-test.js']
};
/* global module */
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// lint tool
jshint: {
all: [
'./*.js',
'lib/**/*.js',
'test/**/*.js'
],
options: {
jshintrc: './.jshintrc'
}
},
// unit tests
buster: {
test: {
}
},
// benchmarks
benchmark: {
all: {
src: ['benchmarks/**/*-benchmark.js'],
dest: 'benchmarks/results.csv',
options: {
times: 100
}
}
},
// documentation
yuidoc: {
compile: {
'name': '<%= pkg.name %>',
'description': '<%= pkg.description %>',
'version': '<%= pkg.version %>',
options: {
paths: 'lib/',
outdir: 'docs'
}
}
},
// a static server that will serve the documenation
connect: {
docs: {
base: 'docs',
port: 8888
}
},
watch: {
scripts: {
files: '<%= jshint.all %>',
tasks: ['clear', 'jshint', 'buster']
},
docs: {
files: [
'lib/**/*.js'
],
tasks: ['yuidoc']
}
}
});
// load tasks
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-clear');
grunt.loadNpmTasks('grunt-buster');
grunt.loadNpmTasks('grunt-benchmark');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-yuidoc');
grunt.loadNpmTasks('grunt-connect');
// shortcuts
grunt.registerTask('docs', 'yuidoc');
grunt.registerTask('test', 'buster');
grunt.registerTask('benchmarks', 'benchmark:all');
// default task
grunt.registerTask('default', ['doc', 'jshint:all', 'buster']);
};
{
"name": "name",
"version": "0.0.1",
"description": "description",
"devDependencies": {
"grunt": ">= 0.4.0rc7",
"grunt-benchmark": ">= 0.1.3",
"grunt-buster": ">= 0.1.2",
"grunt-connect": ">= 0.2.0",
"grunt-contrib-jshint": ">= 0.1.0",
"grunt-contrib-watch": ">= 0.2.0rc7",
"grunt-clear": ">= 0.1.2",
"grunt-contrib-yuidoc": ">= 0.3.2",
"buster": ">= 0.6.12"
},
"dependencies": {
},
"scripts": {
},
"engine": "*"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment