1- /* eslint-disable standard/no-callback-literal */
2-
3- var path = require ( 'path' )
4- var getFile = require ( './get-file' )
5- var compare = require ( './compare-solution' )
1+ const path = require ( 'path' )
2+ const getFile = require ( './get-file' )
3+ const compare = require ( './compare-solution' )
64
75module . exports = function createProblem ( dirname ) {
8- var exports = { }
6+ const exports = { }
97
10- var problemName = dirname . split ( path . sep )
11- var i18n
8+ let problemName = dirname . split ( path . sep )
9+ let i18n
1210
1311 problemName = problemName [ problemName . length - 1 ]
1412
1513 exports . init = function ( workshopper ) {
1614 i18n = workshopper . i18n
17- var postfix = workshopper . i18n . lang ( ) === 'en' ? '' : '_' + workshopper . i18n . lang ( )
15+ const postfix = workshopper . i18n . lang ( ) === 'en' ? '' : '_' + workshopper . i18n . lang ( )
1816 this . problem = { file : path . join ( dirname , 'problem' + postfix + '.md' ) }
1917 this . solution = { file : path . join ( dirname , 'solution' + postfix + '.md' ) }
2018 this . solutionPath = path . resolve ( __dirname , '..' , 'solutions' , problemName , 'index.js' )
2119 this . troubleshootingPath = path . join ( __dirname , '..' , 'i18n' , 'troubleshooting' + postfix + '.md' )
2220 }
2321
2422 exports . verify = function ( args , cb ) {
25- var attemptPath = path . resolve ( process . cwd ( ) , args [ 0 ] )
26- compare ( this . solutionPath , attemptPath , i18n , function ( match , obj ) {
23+ const attemptPath = path . resolve ( process . cwd ( ) , args [ 0 ] )
24+ compare ( this . solutionPath , attemptPath , i18n , function ( _ , match , obj ) {
2725 if ( match ) {
28- return cb ( true )
26+ return cb ( null , true )
2927 }
3028
3129 if ( ! obj ) {
3230 // An error occured, we've already printed an error
3331 return
3432 }
3533
36- var message = getFile ( this . troubleshootingPath )
34+ let message = getFile ( this . troubleshootingPath )
3735
3836 message = message . replace ( / % s o l u t i o n % / g, obj . solution )
3937 message = message . replace ( / % a t t e m p t % / g, obj . attempt )
@@ -45,7 +43,7 @@ module.exports = function createProblem (dirname) {
4543 require ( './footer.js' )
4644 ]
4745
48- cb ( false )
46+ cb ( null , false )
4947 } . bind ( this ) )
5048 }
5149
0 commit comments