@@ -13,20 +13,30 @@ const shell = require('shelljs');
1313const assignment = shell . env [ 'ASSIGNMENT' ] ;
1414const helpers = require ( './helpers' ) ;
1515
16- function copyConfig ( destination ) {
17- helpers . createExercisePackageJson ( ) ;
18- shell . cat ( 'exercise-package.json' ) . to ( destination + '/package.json' ) ;
16+ function copyConfigForAssignment ( assignment ) {
17+ const destination = 'exercises/' + assignment ;
18+ const assignmentPackageFilename = destination + '/package.json' ;
19+ const assignmentVersion = getAssignmentVersion ( assignmentPackageFilename ) ;
20+ helpers . createExercisePackageJson ( assignmentVersion ) ;
21+ shell . cat ( 'exercise-package.json' ) . to ( assignmentPackageFilename ) ;
1922 shell . rm ( 'exercise-package.json' ) ;
2023
2124 shell . cp ( 'babel.config.js' , destination ) ;
2225 shell . cp ( '.eslintrc' , destination ) ;
2326}
2427
28+ function getAssignmentVersion ( assignmentPackageFilename ) {
29+ const packageFile = shell . cat ( assignmentPackageFilename ) . toString ( ) ;
30+ const packageJson = JSON . parse ( packageFile ) ;
31+ console . debug ( packageJson )
32+ return packageJson [ 'version' ] ;
33+ }
34+
2535if ( assignment ) {
2636 shell . echo ( 'Syncing ' + assignment + '...' ) ;
2737 copyConfig ( 'exercises/' + assignment ) ;
2838}
2939else {
3040 shell . echo ( 'Syncing all assignments...' ) ;
31- helpers . assignments . forEach ( assignment => copyConfig ( 'exercises/' + assignment ) ) ;
41+ helpers . assignments . forEach ( copyConfigForAssignment ) ;
3242}
0 commit comments