diff --git a/exercises/components/exercise.js b/exercises/components/exercise.js index 66bf91b..834b978 100644 --- a/exercises/components/exercise.js +++ b/exercises/components/exercise.js @@ -5,6 +5,8 @@ var exercise = require('workshopper-exercise')(); var filecheck = require('workshopper-exercise/filecheck'); var execute = require('workshopper-exercise/execute'); var comparestdout = require('workshopper-exercise/comparestdout'); +var path = require('path'); +var fs = require('fs'); // the output will be long lines so make the comparison take that into account exercise.longCompareOutput = true; @@ -14,6 +16,18 @@ exercise = filecheck(exercise); // execute the solution and submission in parallel with spawn() exercise = execute(exercise); +exercise.getSolutionFiles= function (callback) { + var solutionDir = path.join(this.dir, './solution'); + + fs.readdir(solutionDir, function (err, list) { + if (err) return callback(err); + list.push("views/index.jsx"); + list = list + .filter(function (f) { return (/\.js.*$/).test(f) }) + .map(function (f) { return path.join(solutionDir, f)}); + callback(null, list); + }); +} function rndport() { return 1024 + Math.floor(Math.random() * 64511); diff --git a/exercises/css/exercise.js b/exercises/css/exercise.js index 66bf91b..834b978 100644 --- a/exercises/css/exercise.js +++ b/exercises/css/exercise.js @@ -5,6 +5,8 @@ var exercise = require('workshopper-exercise')(); var filecheck = require('workshopper-exercise/filecheck'); var execute = require('workshopper-exercise/execute'); var comparestdout = require('workshopper-exercise/comparestdout'); +var path = require('path'); +var fs = require('fs'); // the output will be long lines so make the comparison take that into account exercise.longCompareOutput = true; @@ -14,6 +16,18 @@ exercise = filecheck(exercise); // execute the solution and submission in parallel with spawn() exercise = execute(exercise); +exercise.getSolutionFiles= function (callback) { + var solutionDir = path.join(this.dir, './solution'); + + fs.readdir(solutionDir, function (err, list) { + if (err) return callback(err); + list.push("views/index.jsx"); + list = list + .filter(function (f) { return (/\.js.*$/).test(f) }) + .map(function (f) { return path.join(solutionDir, f)}); + callback(null, list); + }); +} function rndport() { return 1024 + Math.floor(Math.random() * 64511); diff --git a/exercises/hello_react/exercise.js b/exercises/hello_react/exercise.js index 66bf91b..a930d25 100644 --- a/exercises/hello_react/exercise.js +++ b/exercises/hello_react/exercise.js @@ -5,6 +5,8 @@ var exercise = require('workshopper-exercise')(); var filecheck = require('workshopper-exercise/filecheck'); var execute = require('workshopper-exercise/execute'); var comparestdout = require('workshopper-exercise/comparestdout'); +var path = require('path'); +var fs = require('fs'); // the output will be long lines so make the comparison take that into account exercise.longCompareOutput = true; @@ -14,7 +16,19 @@ exercise = filecheck(exercise); // execute the solution and submission in parallel with spawn() exercise = execute(exercise); - +exercise.getSolutionFiles= function (callback) { + var solutionDir = path.join(this.dir, './solution'); + + fs.readdir(solutionDir, function (err, list) { + if (err) return callback(err); + list.push("views/index.jsx"); + list = list + .filter(function (f) { return (/\.js.*$/).test(f) }) + .map(function (f) { return path.join(solutionDir, f)}); + callback(null, list); + }); +} + function rndport() { return 1024 + Math.floor(Math.random() * 64511); } diff --git a/exercises/props/exercise.js b/exercises/props/exercise.js index 66bf91b..834b978 100644 --- a/exercises/props/exercise.js +++ b/exercises/props/exercise.js @@ -5,6 +5,8 @@ var exercise = require('workshopper-exercise')(); var filecheck = require('workshopper-exercise/filecheck'); var execute = require('workshopper-exercise/execute'); var comparestdout = require('workshopper-exercise/comparestdout'); +var path = require('path'); +var fs = require('fs'); // the output will be long lines so make the comparison take that into account exercise.longCompareOutput = true; @@ -14,6 +16,18 @@ exercise = filecheck(exercise); // execute the solution and submission in parallel with spawn() exercise = execute(exercise); +exercise.getSolutionFiles= function (callback) { + var solutionDir = path.join(this.dir, './solution'); + + fs.readdir(solutionDir, function (err, list) { + if (err) return callback(err); + list.push("views/index.jsx"); + list = list + .filter(function (f) { return (/\.js.*$/).test(f) }) + .map(function (f) { return path.join(solutionDir, f)}); + callback(null, list); + }); +} function rndport() { return 1024 + Math.floor(Math.random() * 64511); diff --git a/exercises/props_from_server/exercise.js b/exercises/props_from_server/exercise.js index 48f00fc..9d0cd76 100644 --- a/exercises/props_from_server/exercise.js +++ b/exercises/props_from_server/exercise.js @@ -5,6 +5,8 @@ var exercise = require('workshopper-exercise')(); var filecheck = require('workshopper-exercise/filecheck'); var execute = require('workshopper-exercise/execute'); var comparestdout = require('workshopper-exercise/comparestdout'); +var path = require('path'); +var fs = require('fs'); // the output will be long lines so make the comparison take that into account exercise.longCompareOutput = true; @@ -14,6 +16,18 @@ exercise = filecheck(exercise); // execute the solution and submission in parallel with spawn() exercise = execute(exercise); +exercise.getSolutionFiles= function (callback) { + var solutionDir = path.join(this.dir, './solution'); + + fs.readdir(solutionDir, function (err, list) { + if (err) return callback(err); + list.push("views/index.jsx"); + list = list + .filter(function (f) { return (/\.js.*$/).test(f) }) + .map(function (f) { return path.join(solutionDir, f)}); + callback(null, list); + }); +} function rndport() { return 1024 + Math.floor(Math.random() * 64511); diff --git a/exercises/proptypes/exercise.js b/exercises/proptypes/exercise.js index 66bf91b..834b978 100644 --- a/exercises/proptypes/exercise.js +++ b/exercises/proptypes/exercise.js @@ -5,6 +5,8 @@ var exercise = require('workshopper-exercise')(); var filecheck = require('workshopper-exercise/filecheck'); var execute = require('workshopper-exercise/execute'); var comparestdout = require('workshopper-exercise/comparestdout'); +var path = require('path'); +var fs = require('fs'); // the output will be long lines so make the comparison take that into account exercise.longCompareOutput = true; @@ -14,6 +16,18 @@ exercise = filecheck(exercise); // execute the solution and submission in parallel with spawn() exercise = execute(exercise); +exercise.getSolutionFiles= function (callback) { + var solutionDir = path.join(this.dir, './solution'); + + fs.readdir(solutionDir, function (err, list) { + if (err) return callback(err); + list.push("views/index.jsx"); + list = list + .filter(function (f) { return (/\.js.*$/).test(f) }) + .map(function (f) { return path.join(solutionDir, f)}); + callback(null, list); + }); +} function rndport() { return 1024 + Math.floor(Math.random() * 64511); diff --git a/exercises/state/exercise.js b/exercises/state/exercise.js index 66bf91b..834b978 100644 --- a/exercises/state/exercise.js +++ b/exercises/state/exercise.js @@ -5,6 +5,8 @@ var exercise = require('workshopper-exercise')(); var filecheck = require('workshopper-exercise/filecheck'); var execute = require('workshopper-exercise/execute'); var comparestdout = require('workshopper-exercise/comparestdout'); +var path = require('path'); +var fs = require('fs'); // the output will be long lines so make the comparison take that into account exercise.longCompareOutput = true; @@ -14,6 +16,18 @@ exercise = filecheck(exercise); // execute the solution and submission in parallel with spawn() exercise = execute(exercise); +exercise.getSolutionFiles= function (callback) { + var solutionDir = path.join(this.dir, './solution'); + + fs.readdir(solutionDir, function (err, list) { + if (err) return callback(err); + list.push("views/index.jsx"); + list = list + .filter(function (f) { return (/\.js.*$/).test(f) }) + .map(function (f) { return path.join(solutionDir, f)}); + callback(null, list); + }); +} function rndport() { return 1024 + Math.floor(Math.random() * 64511);