@@ -34,7 +34,7 @@ TutorialImporter.prototype.sync = function* (directory) {
3434 var dir = fs . realpathSync ( directory ) ;
3535 var type ;
3636 while ( true ) {
37- if ( dir . endsWith ( '.view' ) ) {
37+ if ( dir . endsWith ( '.view' ) && ! dir . endsWith ( '/_js.view' ) ) {
3838 type = 'View' ;
3939 break ;
4040 }
@@ -63,8 +63,12 @@ TutorialImporter.prototype.sync = function* (directory) {
6363 var parentSlug = path . basename ( parentDir ) ;
6464 parentSlug = parentSlug . slice ( parentSlug . indexOf ( '-' ) + 1 ) ;
6565
66- var parent = yield Article . findOne ( { slug : parentSlug } ) . exec ( ) ;
67-
66+ var parent ;
67+ if ( fs . existsSync ( path . join ( parentDir , 'task.md' ) ) ) {
68+ parent = yield Task . findOne ( { slug : parentSlug } ) . exec ( ) ;
69+ } else {
70+ parent = yield Article . findOne ( { slug : parentSlug } ) . exec ( ) ;
71+ }
6872 yield * this [ 'sync' + type ] ( dir , parent ) ;
6973
7074} ;
@@ -305,10 +309,11 @@ function* importImage(srcPath, dstDir) {
305309
306310function copySync ( srcPath , dstPath ) {
307311 if ( checkSameMtime ( srcPath , dstPath ) ) {
312+ log . debug ( "copySync: same mtime %s = %s" , srcPath , dstPath ) ;
308313 return ;
309314 }
310315
311- log . debug ( "Copy %s to %s" , srcPath , dstPath ) ;
316+ log . debug ( "copySync %s -> %s" , srcPath , dstPath ) ;
312317
313318 fse . copySync ( srcPath , dstPath ) ;
314319}
@@ -384,18 +389,15 @@ TutorialImporter.prototype.syncTask = function*(taskPath, parent) {
384389
385390TutorialImporter . prototype . syncView = function * ( dir , parent ) {
386391
387- log . info ( "syncView" , dir ) ;
388-
392+ log . info ( "syncView: dir" , dir ) ;
389393 var pathName = path . basename ( dir ) . replace ( '.view' , '' ) ;
390-
391394 if ( pathName == '_js' ) {
392395 throw new Error ( "Must not syncView " + pathName ) ;
393396 }
394397
395398 var webPath = parent . getResourceWebRoot ( ) + '/' + pathName ;
396399
397400 log . debug ( "syncView webpath" , webPath ) ;
398-
399401 var plunk = yield Plunk . findOne ( { webPath : webPath } ) . exec ( ) ;
400402
401403 if ( plunk ) {
0 commit comments