@@ -8,16 +8,18 @@ module.exports = function createProblem(dirname) {
88 var problemName = dirname . split ( path . sep ) ;
99 problemName = problemName [ problemName . length - 1 ] ;
1010
11- exports . problem = getFile ( path . join ( dirname , 'problem.md' ) ) ;
12- exports . solution = getFile ( path . join ( dirname , 'solution.md' ) ) ;
13-
14- var solutionPath = path . resolve ( dirname , "../../solutions" , problemName , "index.js" ) ;
15- var troubleshootingPath = path . join ( dirname , '../../troubleshooting.md' ) ;
11+ exports . init = function ( workshopper ) {
12+ var postfix = workshopper . lang === 'en' ? '' : '_' + workshopper . lang ;
13+ this . problem = getFile ( path . join ( dirname , 'problem' + postfix + '.md' ) ) ;
14+ this . solution = getFile ( path . join ( dirname , 'solution' + postfix + '.md' ) ) ;
15+ this . solutionPath = path . resolve ( dirname , "../../solutions" , problemName , "index.js" ) ;
16+ this . troubleshootingPath = path . join ( dirname , '../../troubleshooting' + postfix + '.md' ) ;
17+ }
1618
1719 exports . verify = function ( args , cb ) {
1820
1921 var attemptPath = path . resolve ( process . cwd ( ) , args [ 0 ] ) ;
20- compare ( solutionPath , attemptPath , function ( match , obj ) {
22+ compare ( this . solutionPath , attemptPath , function ( match , obj ) {
2123
2224 if ( match ) {
2325 return cb ( true ) ;
@@ -28,7 +30,7 @@ module.exports = function createProblem(dirname) {
2830 return ;
2931 }
3032
31- var message = getFile ( troubleshootingPath ) ;
33+ var message = getFile ( this . troubleshootingPath ) ;
3234
3335 message = message . replace ( / % s o l u t i o n % / g, obj . solution ) ;
3436 message = message . replace ( / % a t t e m p t % / g, obj . attempt ) ;
@@ -39,7 +41,7 @@ module.exports = function createProblem(dirname) {
3941
4042 cb ( false ) ;
4143
42- } ) ;
44+ } . bind ( this ) ) ;
4345 } ;
4446
4547 exports . run = function ( args ) {
0 commit comments