var gulp = require('gulp');
var livereload = require('gulp-livereload');
var path = require('path');
var config = require('./build-config.js');




var updateActiveProblem = function (filename) {
  config.activeProblem = config.problemDir.concat('/'+ filename + '.js');
};

// Reload the specRunner.html file after changes to its related
// Javascript, including spec and source files.
gulp.task('default', function () {

  // Create Glob pattern to include test scripts and toy problem
  // source code.
  var toyProblemSrc = config.problemDir.concat('/**/*.js');

  // Start Livereload
  livereload.listen();

  // Make sure Gulp watches the actively-edited toy problem and
  // its support files and reloads the associated spec runner.
  gulp.watch(toyProblemSrc, function (file) {
    var editedDirname =  path.basename(path.dirname(file.path));
    var specRunnerHTML = config.problemDir.concat('/'+ editedDirname +'/index.html');

    updateActiveProblem(editedDirname);
    livereload.reload(specRunnerHTML);
  });
});

gulp.task('check-syntax', function () {

  return gulp.src(config.activeProblem)
    .pipe(jshint())
    .pipe(jshint.reporter(stylish))
    .pipe(jshint.reporter('fail'));
});


@@ -1,81 +1,36 @@
 var 
-gulp = require('gulp');%0Avar livereload = require('gulp-livereload
+path = require('path
 ');%0Avar 
 path
@@ -21,30 +21,29 @@
 path');%0Avar 
-path
+fs
  =
+ 
  require('pa
@@ -32,36 +32,34 @@
  fs =  require('
-path
+fs
 ');%0Avar config =
@@ -93,268 +93,215 @@
 ');%0A
-%0A%0A%0A%0Avar updateActiveProblem = function (filename) %7B%0A  config.activeProblem = config.problemDir.concat('/'+ filename + '.js');%0A%7D;%0A%0A// Reload the specRunner.html file after changes to its related%0A// Javascript, including spec and source files.%0Agulp.task('default
+var gulp = require('gulp');%0Avar livereload = require('gulp-livereload');%0Avar jshint = require('gulp-jshint');%0Avar stylish = require('jshint-stylish');%0A%0A%0Agulp.task('default', %5B'startup'%5D);%0A%0Agulp.task('startup
 ', f
@@ -403,26 +403,19 @@
 .%0A  var 
-toyProblem
+dev
 Src = co
@@ -506,129 +506,46 @@
  // 
-Make sure Gulp watches the actively-edited toy problem and%0A  // its support files and reloads the associated spec runner.
+Watch all toy problem and test scripts
 %0A  g
@@ -558,18 +558,11 @@
 tch(
-toyProblem
+dev
 Src,
@@ -588,29 +588,57 @@
     var 
-editedDirname
+pd = config.problemDir;%0A    var activeDir
  =  path
@@ -698,33 +698,84 @@
 rHTML = 
-config.p
+pd.concat('/'+ activeDir, '/index.html');%0A    var activeP
 roblem
-Dir
+ = pd
 .concat(
@@ -783,211 +783,1064 @@
 /'+ 
-editedDirname +'/index.html');%0A%0A    updateActiveProblem(editedDirname);%0A    livereload.reload(specRunnerHTML);%0A  %7D);%0A%7D);%0A%0Agulp.task('check-syntax', function () %7B%0A%0A  return gulp.src(config.active
+activeDir, '/'+ activeDir +'.js');%0A%0A    // Lint JS files in background. Warnings are output to the %0A    // console. Errors are caught by the interpreter upon reload. %0A    gulp.src(activeProblem)%0A      .pipe(jshint())%0A      .pipe(jshint.reporter(stylish));%0A%0A    // Reload the spec runner associated with the active problem.%0A    livereload.reload(specRunnerHTML);%0A  %7D);%0A%7D);%0A%0Agulp.task('validate', function (cb) %7B%0A  var toyProblems = %5B%5D;%0A%0A  fs.readdir(config.problemDir, function (err, files) %7B%0A    if (err) throw err;%0A%0A    // Set toyProblems by filtering out hidden directory in a%0A    // somewhat janky way, then configuring paths to each%0A    // remaining directory's source file.%0A    files%0A      .filter(function (fn) %7Breturn fn.charAt(0) != '.';%7D)%0A      .forEach(function (fp)%7B%0A        var name = '/'+ fp;%0A        toyProblems.push(config.problemDir.concat(name, name +'.js'));%0A      %7D);%0A%0A    // Lint toyProblems. Warning and Errors output to the%0A    // console and break the build, requiring 'gulp startup'%0A    // to restart.%0A    gulp.src(toy
 Problem
+s
 )%0A
+    
     
@@ -1855,24 +1855,28 @@
 hint())%0A    
+ 
+   
 .pipe(jshint
@@ -1895,24 +1895,28 @@
 ylish))%0A    
+   
+ 
 .pipe(jshint
@@ -1935,13 +1935,29 @@
 ail'));%0A
+%0A    cb();%0A  
 %7D);%0A
+%7D);
 %0A

Add validate task to run jshint on all toy problems