@@ -3,13 +3,12 @@ import fs from 'fs-extra';
33import path from 'path' ;
44import browserify from 'browserify' ;
55import getChallenges from './getChallenges' ;
6- import { UnpackedChallenge , ChallengeFile } from './unpackedChallenge' ;
6+ import { UnpackedChallenge , ChallengeFile } from './unpackedChallenge' ;
77
88// Unpack all challenges
99// from all seed/challenges/00-foo/bar.json files
1010// into seed/unpacked/00-foo/bar/000-id.html files
1111//
12- // todo: unpack translations too
1312// todo: use common/app/routes/Challenges/utils/index.js:15 maps
1413// to determine format/style for non-JS tests
1514// todo: figure out embedded images etc. served from elsewhere in the project
@@ -19,7 +18,7 @@ let unpackedDir = path.join(__dirname, 'unpacked');
1918
2019// bundle up the test-running JS
2120function createUnpackedBundle ( ) {
22- fs . mkdirp ( unpackedDir , ( err ) => {
21+ fs . mkdirp ( unpackedDir , err => {
2322 if ( err && err . code !== 'EEXIST' ) {
2423 console . log ( err ) ;
2524 throw err ;
@@ -28,8 +27,7 @@ function createUnpackedBundle() {
2827 let unpackedFile = path . join ( __dirname , 'unpacked.js' ) ;
2928 let b = browserify ( unpackedFile ) . bundle ( ) ;
3029 b . on ( 'error' , console . error ) ;
31- let unpackedBundleFile =
32- path . join ( unpackedDir , 'unpacked-bundle.js' ) ;
30+ let unpackedBundleFile = path . join ( unpackedDir , 'unpacked-bundle.js' ) ;
3331 const bundleFileStream = fs . createWriteStream ( unpackedBundleFile ) ;
3432 bundleFileStream . on ( 'finish' , ( ) => {
3533 console . log ( 'Wrote bundled JS into ' + unpackedBundleFile ) ;
@@ -50,8 +48,9 @@ async function cleanUnpackedDir(unpackedChallengeBlockDir) {
5048 filePath = path . join ( unpackedChallengeBlockDir , filePath ) ;
5149 return new Promise ( ( ) => fs . unlink ( filePath ) ) ;
5250 } ;
53- let promises = fs . readdirSync ( unpackedChallengeBlockDir )
54- . filter ( filePath => ( / \. h t m l $ / i) . test ( filePath ) )
51+ let promises = fs
52+ . readdirSync ( unpackedChallengeBlockDir )
53+ . filter ( filePath => / \. h t m l $ / i. test ( filePath ) )
5554 . map ( promiseToDelete ) ;
5655 await Promise . all ( promises ) ;
5756}
@@ -64,7 +63,7 @@ function unpackChallengeBlock(challengeBlock) {
6463 challengeBlockPath . name
6564 ) ;
6665
67- fs . mkdirp ( unpackedChallengeBlockDir , ( err ) => {
66+ fs . mkdirp ( unpackedChallengeBlockDir , err => {
6867 if ( err && err . code !== 'EEXIST' ) {
6968 console . log ( err ) ;
7069 throw err ;
@@ -83,11 +82,11 @@ function unpackChallengeBlock(challengeBlock) {
8382 delete challengeBlock . fileName ;
8483 delete challengeBlock . superBlock ;
8584 delete challengeBlock . superOrder ;
86- let challengeBlockCopy =
87- new ChallengeFile (
88- unpackedChallengeBlockDir ,
89- challengeBlockPath . name ,
90- '.json' ) ;
85+ let challengeBlockCopy = new ChallengeFile (
86+ unpackedChallengeBlockDir ,
87+ challengeBlockPath . name ,
88+ '.json'
89+ ) ;
9190 challengeBlockCopy . write ( JSON . stringify ( challengeBlock , null , 2 ) ) ;
9291
9392 // unpack each challenge into an HTML file
@@ -104,7 +103,7 @@ function unpackChallengeBlock(challengeBlock) {
104103}
105104
106105createUnpackedBundle ( ) ;
107- let challenges = getChallenges ( ) ;
106+ let challenges = getChallenges ( null , true ) ;
108107challenges . forEach ( challengeBlock => {
109108 unpackChallengeBlock ( challengeBlock ) ;
110109} ) ;
0 commit comments