Skip to content

Commit

Permalink
Merge branch 'master' into WardPlay
Browse files Browse the repository at this point in the history
  • Loading branch information
wardbell committed Sep 14, 2014
2 parents 84cd9b2 + b6956af commit 1901f24
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 80 deletions.
25 changes: 24 additions & 1 deletion modular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,32 @@ gulp.src('', {read: false})
Run `gulp serve-dev-debug` or `gulp serve-dev-debug-brk` to debug node via the Gulp tasks in this project.

### Issues
If a process stays connected find it and kill with these commands

####If a process stays connected find it and kill with these commands

```
lsof -i TCP|fgrep LISTEN
kill -9 34608
```

####Set up some aliases for the Mac

Edit the bash profile

nano ~/.bash_profile

Enter the aliases

/usr/local/bin
alias lsp='sudo lsof -i -n -P | grep LISTEN'

alias cdmod='cd _git/ng-demos/modular'

alias gadd='git add . -A'

CTRL-X and save

Source the file

source ~/.bash_profile

135 changes: 79 additions & 56 deletions modular/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,13 @@
var gulp = require('gulp');
var pkg = require('./package.json');
var common = require('./gulp/common.js');
var karma = require('karma').server;
var plug = require('gulp-load-plugins')();
var env = plug.util.env;
var log = plug.util.log;

gulp.task('help', plug.taskListing);

/**
* @desc Annotate only
* Mostly for show.
* See the output of each file?
* Uncomment rename, comment concat and uglify
* See min'd and concat'd output?
* Comment rename, uncomment concat and uglify,
* add to index.html, then run it with `gulp serve-dev`.
*/
gulp.task('ngAnnotateTest', function() {
log('Annotating AngularJS dependencies');
var source = [].concat(pkg.paths.js);
return gulp
// .src(source)
.src(pkg.paths.client + '/app/avengers/avengers.js')
.pipe(plug.ngAnnotate({add: true, single_quotes: true}))
.pipe(plug.rename(function(path) {
path.extname = '.annotated.js';
}))
// .pipe(plug.concat('all.min.js'))
// .pipe(plug.uglify({mangle: true}))
// .pipe(gulp.dest(pkg.paths.client + '/app'));
.pipe(gulp.dest(pkg.paths.client + '/app/avengers'));
});

/**
* @desc Lint the code
*/
Expand Down Expand Up @@ -256,43 +232,62 @@ gulp.task('watch', function() {
});

/**
* @desc Run non-midway tests
* @example
* gulp test // Run once and then close
* gulp test --watch // Run and keep open with watch
* gulp test --watch --startServers // Start servers, run, and keep open with watch
* Run test once and exit
* gulp autotest --startServers
*/
//gulp.task('test', ['test-serve-midway'], function() {
gulp.task('test', function() {
gulp.task('test', function (done) {
var child;
var excludeFiles = ['./src/client/app/**/*spaghetti.js'];
// var exec = require('child_process').exec;
var savedEnv = process.env;
var spawn = require('child_process').spawn;

if (env.startServers) {
log('Starting servers');
var options = {
script: pkg.paths.server + 'app.js',
env: {'NODE_ENV': 'dev', 'PORT': 8888}
};
plug.nodemon(options);
// child = exec('NODE_ENV=dev PORT=8888 node ' + pkg.paths.server + 'app.js', childCompleted);

savedEnv.NODE_ENV = 'dev';
savedEnv.PORT = 8888;
log(savedEnv);
child = spawn('node', ['src/server/app.js'], {env: savedEnv}, childCompleted);
} else {
excludeFiles.push('./src/client/test/midway/**/*.spec.js');
}
startTests();

function childCompleted(error, stdout, stderr) {
log('stdout: ' + stdout);
log('stderr: ' + stderr);
if (error !== null) {
log('exec error: ' + error);
}
}

log('Running tests');
var action = (env.watch == null || env.watch === 'run') ? 'run' : 'watch';
// var testFiles = [pkg.paths.test + '*[Ss]pec.js'];

return gulp
.src('./useKarmaConfAndNotThis')
.pipe(plug.plumber())
.pipe(plug.karma({
configFile: pkg.paths.test + '/karma.conf.js',
// singleRun: true,
delay: 5, //TODO: this does nada?
action: action // run (once) or watch (keep open)
}))
// .pipe(plug.plumber.stop())
.on('error', function(err) {
// failed tests cause gulp to exit
log(err);
throw err;
function startTests() {
karma.start({
configFile: __dirname + '/karma.conf.js',
exclude: excludeFiles,
singleRun: true
}, function() {
if (child) {child.kill();}
done();
});
}
});

/**
* Watch for file changes and re-run tests on each change
* gulp autotest --startServers // Start servers, run, and keep open with watch
*/
gulp.task('autotest', function (done) {
var excludeFiles = [
'./src/client/app/**/*spaghetti.js',
'./src/client/test/midway/**/*.spec.js'
];
karma.start({
configFile: __dirname + '/karma.conf.js',
exclude: excludeFiles
}, done);
});

/**
Expand Down Expand Up @@ -369,4 +364,32 @@ function serve(args) {
.on('restart', function() {
log('restarted!');
});
}
}

/**
* @desc Annotate only
* ONLY USED IN PLURALSIGHT COURSE ANGULARJS PATTERNS: CLEAN CODE
* ONLY FOR DEMO PURPOSES
* ALL OTHER TASKS ARE AWESOME-SAUCE
*
* See the output of each file?
* Uncomment rename, comment concat and uglify
* See min'd and concat'd output?
* Comment rename, uncomment concat and uglify,
* add to index.html, then run it with `gulp serve-dev`.
*/
gulp.task('ngAnnotateTest', function() {
log('Annotating AngularJS dependencies');
var source = [].concat(pkg.paths.js);
return gulp
// .src(source)
.src(pkg.paths.client + '/app/avengers/avengers.js')
.pipe(plug.ngAnnotate({add: true, single_quotes: true}))
.pipe(plug.rename(function(path) {
path.extname = '.annotated.js';
}))
// .pipe(plug.concat('all.min.js'))
// .pipe(plug.uglify({mangle: true}))
// .pipe(gulp.dest(pkg.paths.client + '/app'));
.pipe(gulp.dest(pkg.paths.client + '/app/avengers'));
});
46 changes: 23 additions & 23 deletions modular/src/client/test/karma.conf.js → modular/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,49 @@ module.exports = function (config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '../../',
basePath: './',

// frameworks to use
// some available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'chai', 'sinon', 'chai-sinon'],

// list of files / patterns to load in the browser
files: [
'./client/test/bindPolyfill.js',
'./src/client/test/bindPolyfill.js',

'./../node_modules/ng-midway-tester/src/ngMidwayTester.js',
'./node_modules/ng-midway-tester/src/ngMidwayTester.js',

'./../bower_components/jquery/dist/jquery.js',
'./../bower_components/angular/angular.js',
'./../bower_components/angular-mocks/angular-mocks.js',
'./../bower_components/angular-animate/angular-animate.js',
'./../bower_components/angular-route/angular-route.js',
'./../bower_components/angular-sanitize/angular-sanitize.js',
'./../bower_components/bootstrap/dist/js/bootstrap.js',
'./../bower_components/toastr/toastr.js',
'./../bower_components/moment/moment.js',
'./../bower_components/extras.angular.plus/ngplus-overlay.js',
'./bower_components/jquery/dist/jquery.js',
'./bower_components/angular/angular.js',
'./bower_components/angular-mocks/angular-mocks.js',
'./bower_components/angular-animate/angular-animate.js',
'./bower_components/angular-route/angular-route.js',
'./bower_components/angular-sanitize/angular-sanitize.js',
'./bower_components/bootstrap/dist/js/bootstrap.js',
'./bower_components/toastr/toastr.js',
'./bower_components/moment/moment.js',
'./bower_components/extras.angular.plus/ngplus-overlay.js',

'./client/app/app.module.js',
'./client/app/**/*.module.js',
'./client/app/**/*.js',
'./src/client/app/app.module.js',
'./src/client/app/**/*.module.js',
'./src/client/app/**/*.js',

/* MOCHA */
'./client/test/**/specHelper.js',
'./src/client/test/**/specHelper.js',

'./client/test/basics/**/*.src.js',
'./client/test/basics/**/*.spec.js',
'./src/client/test/basics/**/*.src.js',
'./src/client/test/basics/**/*.spec.js',

// all specs ... comment out during early test training
'./client/test/**/*.spec.js'
'./src/client/test/**/*.spec.js'

],

// list of files to exclude
exclude: [
// Excluding midway tests for now; comment this line out when you want to run them
'./client/test/spec.mocha/midway/**/*.spec.js',
'./client/app/**/*spaghetti.js'
'./src/client/test/midway/**/*.spec.js',
'./src/client/app/**/*spaghetti.js'
],

proxies: {
Expand All @@ -57,7 +57,7 @@ module.exports = function (config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'client/app/**/*.js': 'coverage'
'src/client/app/**/*.js': 'coverage'
},

// test results reporter to use
Expand Down

0 comments on commit 1901f24

Please sign in to comment.